NSLog(@"lets test if this is called (before)");
HelloWorldLayer *helloWorldLayer = [HelloWorldLayer node];
//calling HelloWorldLayer
id moveup = [CCMoveBy actionWithDuration:0.1 position:ccp(0, 5)];
[helloWorldLayer.player runAction:moveup];
NSLog(@"lets test if this is called (after)");
所以基本上我寫了這個代碼和NSLogs都工作正常,但我的球員精靈不動...我不認爲代碼(CCMoveBy)是錯誤的。所以首先我認爲它沒有調用HelloWorldLayer,所以我嘗試了這個。[cocos2d中]利用HelloWorldLayer CCSprite其他類
我把這段代碼放到了我的其他類中。
HelloWorldLayer *helloWorldLayer = [HelloWorldLayer node];
//calling HelloWorldLayer
[helloWorldLayer moveMyCharacter];
這個代碼我HelloWorldLayer
-(void)moveMyCharacter
NSLog(@"MOVE UP");
id moveup = [CCMoveBy actionWithDuration:0.1 position:ccp(0, 5)];
[_player runAction:moveup];
和NSLog的工作,但性格不動......
我需要一些幫助:(
你似乎在1/6秒內將你的角色移動5個像素。你會注意到這麼小的快速移動嗎?嘗試移動它更慢更遠。 – willc2