ZwoptexManager WiEngine Android中出现多个纹理加载问题

时间:2011-12-14 13:02:28

标签: android

我正在研究Wi-Engine,目前在将两张纸装入zwoptex管理器时遇到了问题。

在下面的代码中,我正在加载两张(sheeta和sheetb),其中包含两个动画,这两个动画存储为类中的动作(firstAction,secondAction)。稍后当我在精灵按钮上单击runAction时,firstAction运行正常,但 secondAction使用firstAction的纹理和第二个的帧,这会导致意外的结果。如果你能让我知道我错过了什么或做错了。

`

/******** Loading Sheet 1********/


Texture2D tex = Texture2D.makePNG(R.drawable.sheeta);
ZwoptexManager.addZwoptex("sheeta", R.raw.sheeta,  tex);


/******** Loading Sheet 2********/


Texture2D tex2 = Texture2D.makePNG(R.drawable.sheetb);
ZwoptexManager.addZwoptex("sheetb",  R.raw.sheetb,tex2);


petSprite = ZwoptexManager.makeSprite("image_1.png"); // image_1 is in Sheeta

/******* Creating Animations and Actions    ******/
Animation firstAnimation = new Animation(0);

for (int i = 1; i <= 9; i++) 
{
    firstAnimation.addFrame(0.1f, ZwoptexManager.getFrameRect("sheeta",             "image_" + i + ".png"));
}


Animate a = (Animate)Animate.make(firstAnimation).autoRelease();
firstAction = (Action)Repeat.make(a, 2);

Animation secondAnimation = new Animation(0);

for (int i = 10; i <= 20; i++) 
{
    secondAnimation.addFrame(0.1f, ZwoptexManager.getFrameRect("sheetb",
                    "image_" + i + ".png"));
}
Animate b = (Animate)Animate.make(secondAnimation).autoRelease();
secondAction = (Action)Repeat.make(b, 1);

`

1 个答案:

答案 0 :(得分:0)

对于那些遇到同样问题的人来说,以下是让动画正常工作的正确方法。

Animation secondAnimation = new Animation(0);
for (int i = 52; i <= 65; i++) 
{
    SpriteFrame temp = ZwoptexManager.getSpriteFrame("sheetb","image_" + i + ".png");
    temp.setDuration(0.1f);
    secondAnimation.addFrame(temp);
}
Animate temp = (Animate)Animate.make(secondAnimation).autoRelease();
Action firstAction = (Action)Repeat.make(temp, 1);