sourcemars / cocos2d-android-1

Automatically exported from code.google.com/p/cocos2d-android-1
0 stars 0 forks source link

the method's params when called by schedule("myMethod") and CCCallFuncN.action(this,"myMethod") #60

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
To make schedule("myMethod")  's myMethod() to be called,
myMethod must be defined like:
public void myMethod(float dt){}

or will not get called.

 To make CCCallFuncN.action(this,"myMethod")  's myMethod() to be called,
myMethod must be defined like:
public void myMethod(Object sender){}

or will not get called.

so my problem is when schedule("myMethod") and 
CCCallFuncN.action(this,"myMethod") call the same myMethod() ,how to set 
myMethod's param? 

Original issue reported on code.google.com by walkerD...@gmail.com on 26 Mar 2011 at 7:29

GoogleCodeExporter commented 8 years ago
ok, I found a solution.
You can define the method like this:

(if the method do the same thing)
public void myMethod(float dt){
     //the thing I wanna do
}

public void myMethod(Object sender){
    this.myMethod(0.0f);
}

Original comment by walkerD...@gmail.com on 26 Mar 2011 at 7:56

GoogleCodeExporter commented 8 years ago
ok, I found a solution.
You can define the method like this:

(if the method do the same thing)
public void myMethod(float dt){
     //the thing I wanna do
}

public void myMethod(Object sender){
    this.myMethod(0.0f);
}

Original comment by walkerD...@gmail.com on 26 Mar 2011 at 7:56

GoogleCodeExporter commented 8 years ago
Hi,
I tried your solution, but I have a problem: I have two method like you. First 
is CCCallFuncN.action(this,"myMethod") and second is scheduled method like your 
method.
When I start application and press on object first method call second method 
and application crash down.

Here is an error code:

04-20 15:38:05.256: ERROR/AndroidRuntime(258): Uncaught handler: thread 
GLThread 8 exiting due to uncaught exception
04-20 15:38:05.356: ERROR/AndroidRuntime(258): 
java.lang.IndexOutOfBoundsException
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
java.util.ArrayList.remove(ArrayList.java:507)
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
org.cocos2d.actions.CCActionManager.removeAction(CCActionManager.java:102)
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
org.cocos2d.actions.CCActionManager.update(CCActionManager.java:314)
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
org.cocos2d.actions.CCScheduler.tick(CCScheduler.java:192)
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:692)
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
org.cocos2d.nodes.CCDirector.onDrawFrame(CCDirector.java:663)
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1127)
04-20 15:38:05.356: ERROR/AndroidRuntime(258):     at 
android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)

Can you help me ? Thanks

Original comment by hajek.mi...@gmail.com on 20 Apr 2011 at 1:42

GoogleCodeExporter commented 8 years ago
Hi,
new version of cocos fixed this problem Thanks :)

Original comment by hajek.mi...@gmail.com on 22 Apr 2011 at 6:40