發現CCSprite類別的成員
如果要在init以外的地方重新設定位置
似乎不那麼容易
例如以下程式碼
clothe = [CCSprite spriteWithFile:@"clothe.png"]; clothe.position = ccp(100,100); [self addChild:clothe];
這是在init初始的一個衣服成員
一開始就設定好在(100,100)的地方
之後我在別的函式想要重新SetPosition
卻發現無法運作 衣服不會移動位置
追查後發現解決方法
程式碼如下
[clothe stopAllActions]; [clothe setPosition:ccp(200,100)];
關鍵就是要先stopAllActions
以上
沒有留言:
張貼留言