Flex/Starling 게임을 개발하고 모든 Sprite 호출을 최적화하기 위해 Atlas Texture를 사용하고 싶습니다. 내 문제는 내가 명확하고 간단한 코드를 사용하여 기본 ressources 및 실행할 수 없습니다, 나는 인수 오류, 텍스처 null이 될 수 없다는 것입니다. , 내 코드 나는 .getTexture 방법은 아무것도 찾을 수 없다는 것을 이해하지만, 내가이 문제를 해결하는 방법을 참조 해달라고 :Starling, Atlas Texture "텍스처는 null이 될 수 없습니다."
[Embed(source = "Atlas_bg/AtlasBackground.xml")]
public var AtlasXml:Class
[Embed(source = "Atlas_bg/AtlasBackground.png")]
public var AtlasPng:Class
// create atlas
var texture:Texture = Texture.fromBitmap(new AtlasPng());
var xml:XML = XML(new AtlasXml());
var atlas:TextureAtlas = new TextureAtlas(texture, xml);
// display a sub-texture
var objsTexture:Texture = atlas.getTexture("star_0");// ne trouve rien
var objsImage:Image = new Image(objsTexture);
addChildAt(objsImage, 0.6);
objsImage.x = 200;
objsImage.y = 200;
XML 내용 :
<TextureAtlas imagePath="AtlasBackground.png">
<SubTexture name="star_0" x="2" y="2" width="20" height="20"/>
<SubTexture name="star_1" x="2" y="24" width="20" height="20"/>
</TextureAtlas>
들으을.
그래, 그게 이상해 (오타 일 수도 있음)하지만 오류의 원인은 아닙니다. addChildAt는 int 매개 변수가 전달 된 Number가 정수 부분 (이 경우 0)으로 잘 리므로 제대로 작동해야합니다. – danii