如何在 cocos2d android 1 中创建 cocos2d 粒子效果?

发布于 2024-11-30 22:53:49 字数 1015 浏览 2 评论 0原文

我正在使用位于此处的 android 版本的 cocos2d:

https://github.com/ZhouWeikuan/cocos2d

我是一名 iPhone 用户,正在研究 Android,并且已经熟悉 cocos2d iPhone。理想情况下,我能够从包/包中的 plist 文件创建粒子。我似乎甚至无法让“预制”默认样式粒子工作,即 CCParticleFireworks(不过我只在模拟器中尝试过)。我很失望的是,cocos2d android 的示例代码非常少,所以如果有人对此有很好的资源,我也会感兴趣。我也刚刚学习java,所以这可能很简单,只是寻找一些我基本上可以使用的代码片段。

当我尝试实例化并将粒子添加到场景中时,我在所有尝试中看到的行为只是崩溃。我也不太擅长在 eclise 中进行调试,所以我无法准确地说出应用程序何时死亡。对不起。我正在努力少吸一点我本来想把我的代码放进去,但我尝试了很多不同的方法,但我不想看起来像个混蛋。但无论如何,这就是我认为它应该如何工作:

 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 位于我的资产文件夹中,我觉得我需要将其转换为哈希或其他东西。我还觉得 ccarticlesystem 与 ccpointarticlesystem 与 ccquadParticleSystem 可能存在问题。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

豆芽 2024-12-07 22:53:49

您应该尝试 WiEngine 。它是最好的 Cocos2d java android 移植。 Cocos2d-android 甚至没有实现 3d。班级在那里,但空荡荡的。另请从 android market 查看 Wiengine 的 api 演示

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

紧拥背影 2024-12-07 22:53:49

上次我与作者核实时,他提到 cocos2d-android-1 的 3D 上的场景转换、网格动作和粒子系统存在缺陷。

如果您有 cocos2d-iphone 代码要移植或编码您自己的扩展 的东西,我建议您尝试 cocos2d-x查看

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文