Forum > C# > sel_shedule

sel_shedule

By theshivu Posted 2012-02-29 05:40 Comments 7
theshivu
  • Posts: 21
  • Location: Banglore

hey guys am a beginner for cocos and wp7, i worked with wp7 simple game, now using cocos2dx in it
i had done with this
id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:`selector(spriteMoveFinished:)];
to
CCCallFunc actionMoveDone=CCCallFuncN.actionWithTarget(this,spritemovefinished);

can any help me with this to convert to c# of cocos2dx
[self schedule:`selector( gameLogic: ) interval:1.0]

huangrh
  • Posts: 171

#1 RE: 2012-02-29 06:28

it must be: this.schedule(gameLogic, 1.0f);

theshivu
  • Posts: 21
  • Location: Banglore

#2 RE: 2012-02-29 06:41

thats the thing i did first, but the error is something like
the best overloaded method match for ’cocos2d.CCNode.shedule(cocos2d.SEL_SHEDULE,float) has some
invalid arguments
should i need create SEL_SHEDULE delegate or something,?
i created a simple snske ladder game totally in XNA c#, now am getting hard to learn cocos and then converting it to C# xna, i hope cocos2dx-xna would help a lot, but am not getting a simple sample program to refer for such ,
any way whats that SEL_SHEDULE am facing ?

huangrh
  • Posts: 171

#3 RE: 2012-02-29 06:51

from what you said, you should define gameLogic like this: public void gameLogic(float interval)

theshivu
  • Posts: 21
  • Location: Banglore

#4 RE: 2012-02-29 07:29

CCMoveTo actionmove=CCMoveTo.actionWithDuration(actualDuration,new CCPoint(-tSprite.contentSize.width / 2,actualY));
CCCallFunc actionMoveDone=CCCallFuncN.actionWithTarget(this,spritemovefinished);
tSprite.runAction(CCSequence.actions(actionmove,actionMoveDone));

public void spritemovefinished()
{
// removeChild(tSprite, true);
//this.removeChild(this.tSprite,true);

}

if i didnt remove child it works well , but i facing mscorlib.dll!systemthrowHelper.ThrowKeyNotFoundException()+0X5
error
when i try to remove childs
how should i use the above function to remove those targets frm memory?

arnas
  • Posts: 72

#5 RE: 2012-03-27 13:13

if you change the touches method in hello cocos2d project with

    public override void ccTouchesBegan(List touches, CCEvent event_)
        {
            this.removeChild(this.pSprite, true);
        }

then it works fine, maybe you added pSprite to a batch node and not to class.

Logan
  • Posts: 88

#6 RE: 2012-03-28 05:05

In case you are defining this as a behavior to a class object, then this should work

public void RemoveThisObject()
{
   this.removeFromParentAndCleanup( true );
}
arnas
  • Posts: 72

#7 RE: 2012-03-28 06:34

whats also interesting is that if you call this.removeChild(this.pSprite,true); more than once when the sprite is already removed it wont crash unlike in cocos2dx/c++

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps