如何在android cocos2d中使用plist显示粒子效果?

时间:2012-12-13 06:41:46

标签: android android-emulator cocos2d-android

我正在使用cocos2d在android中做一个小游戏,我想使用plist文件显示粒子效果。我尝试使用下面的代码,但我得到一个nullpointer异常。不使用.png文件,如何显示plist文件?

GamestartLayer.clsss:

      public class GamestartLayer extends CCColorLayer {
    CCSprite ss;
    float movement;

   CGSize winSize = CCDirector.sharedDirector().displaySize();
    protected GamestartLayer(ccColor4B color) {
    super(color);
    // TODO Auto-generated constructor stub

    this.setIsTouchEnabled(true);
     ss=CCSprite.sprite("ant_1_1.png");
       ss.setPosition(CGPoint.ccp(768*0.5f, 1024*0.5f));
    this.addChild(ss,5);
    this.setIsAccelerometerEnabled(true);
    this.schedule("gameLogic"); 
       CCParticleSystem       fire=CCParticleFire.particleWithFile("Rocketfire2.plist");

       fire.setPosition(CGPoint.ccp(winSize.width/2.0f, winSize.height/2.0f));
       this.addChild(fire);
}

public static CCScene scene() {
    // TODO Auto-generated method stub
       CCScene scene = CCScene.node();


         GamestartLayer  layer = new GamestartLayer(ccColor4B.ccc4(225, 225,225, 225));

        //adds layer to scene
        scene.addChild(layer);

        return scene;
}

      }

1 个答案:

答案 0 :(得分:0)

您可以尝试WiEngine。它是最好的Cocos2d java跨平台端口。还可以从android market

查看Wiengine的api Demo