我正在使用以下代码在Android中的Cocos2d游戏中获取粒子效果。
CCParticleSystem particle;
particle=(CCParticleSystem) CCParticleSystem.node();
particle=CCParticleSystem.particleWithFile("myPlist.plist");
particle.setLife(1.0f);
particle.setDuration(1.5f);
particle.setSpeed(100);
addChild(particle);
particle.setAutoRemoveOnFinish(true);
应用程序在运行时崩溃。任何人都可以通过此代码找出问题。
这是logcat。
06-27 15:38:21.266: INFO/WindowManager(5759): Delivering pointer toWindow{4523c980 com.company.Cocos2d.pack/com.company.Cocos2d.pack.Cocos2d_init paused=false}
06-27 15:38:21.286: WARN/dalvikvm(17300): threadid=1: thread exiting with uncaught exception (group=0x400207d8)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): FATAL EXCEPTION: main
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): java.lang.ClassCastException: org.cocos2d.nodes.CCNode
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at com.company.Cocos2d.pack.HelloWorldLayer.ccTouchesBegan(Cocos2d_init.java:178)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at org.cocos2d.events.CCTouchHandler.ccTouchesBegan(CCTouchHandler.java:63)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at org.cocos2d.events.CCTouchDispatcher.touchesBegan(CCTouchDispatcher.java:184)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at org.cocos2d.opengl.CCGLSurfaceView$AsyncEventer.doInBackground(CCGLSurfaceView.java:83)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at org.cocos2d.opengl.CCGLSurfaceView.onTouchEvent(CCGLSurfaceView.java:68)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.view.View.dispatchTouchEvent(View.java:3766)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1714)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1698)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.view.ViewRoot.handleMessage(ViewRoot.java:1787)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.os.Looper.loop(Looper.java:123)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at android.app.ActivityThread.main(ActivityThread.java:4628)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at java.lang.reflect.Method.invoke(Method.java:521)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:879)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:637)
06-27 15:38:21.366: ERROR/AndroidRuntime(17300): at dalvik.system.NativeStart.main(Native Method)
06-27 15:38:21.376: WARN/ActivityManager(5759): Force finishing activity com.company.Cocos2d.pack/.Cocos2d_init
06-27 15:38:21.386: INFO/KeyInputQueue(5759): Enqueueing touch event