how do i create a cocos2d particle effect in cocos

2019-02-28 10:57发布

问题:

I'm using the android version of cocos2d located here:

https://github.com/ZhouWeikuan/cocos2d

I'm an iPhone guy checking out android who already has familiarity with cocos2d iPhone. Ideally i would be able to create the particle from a plist file in the package/bundle. I can't seem to even get the "premade" default style particles working ie CCParticleFireworks (I've only tried in the simulator though). I was disappointed that there is very little sample code out there for cocos2d android so if anyone has a good resource on this I would be interested as well. I'm just learning java as well so it may be something simple just looking for some code snippet I can use basically.

The behavior im seeing with all my attempts is just a crash as soon as i try to instantiate and add the particle to the scene. I'm not too great at debugging in eclise either so i can't say exactly when the app is dying. sorry. I'm trying to suck less. I'd put my code in but ive tried it a bunch of different ways and I don't want to look like an ass. but here goes anyway, so here's how i think it should work:

 public boolean ccTouchesBegan(MotionEvent event)
{
    CGPoint location = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(), event.getY()));
    CCParticleSystem part = CCParticleSystem.particleWithFile("0.plist");
    part.setPosition(location.x, location.y);
    addChild(part);


    return true;
}

0.plist is in my assets folder, i feel like i need to turn this into a hash or something. also i feel there might be a problem with the ccparticlesystem vs ccpointparticlesystem vs ccquadParticleSystem.

回答1:

You should try WiEngine . It is the Best Cocos2d java android port. Cocos2d-android don't even have 3d implemented. The classes are there but empty. Also check Wiengine's api Demo from the android market



回答2:

Last time I checked with the author he mentioned that scene transition, grid actions, and particle systems on cocos2d-android-1's 3D are flawed.

I would recommend trying cocos2d-x if you have cocos2d-iphone code to port or coding your own thing extending View.