/**
* FileName : ActionsTest.java
* Comment : 콜백 테스트
* @version : 1.0
* @author : coolsharp
* @date : 2011. 10. 18.
*/
static class ActionSequence2 extends ActionDemo {
public void onEnter() {
super.onEnter();
alignSpritesLeft(1);
// 보이지 않게 설정
grossini.setVisible(false);
// 200, 200에 위치하고 보인 후 100 만큼 오른쪽으로 이동
CCSequence action = CCSequence.actions(CCPlace.action(CGPoint.ccp(200, 200)), CCShow.action(), CCMoveBy.action(1, CGPoint.ccp(100, 0)),
CCCallFunc.action(this, "callback1"), CCCallFuncN.action(this, "callback2"), CCCallFuncND.action(this, "callback3", Float.valueOf(1.0f)));
grossini.runAction(action);
}
public void callback1() {
CGSize s = CCDirector.sharedDirector().winSize();
CCLabel label = CCLabel.makeLabel("callback 1 called", "DroidSans", 16);
label.setPosition(CGPoint.ccp(s.width / 4 * 1, s.height / 2));
addChild(label);
}
public void callback2(Object sender) {
CGSize s = CCDirector.sharedDirector().winSize();
CCLabel label = CCLabel.makeLabel("callback 2 called", "DroidSans", 16);
label.setPosition(CGPoint.ccp(s.width / 4 * 2, s.height / 2));
addChild(label);
}
public void callback3(Object sender, Object data) {
CGSize s = CCDirector.sharedDirector().winSize();
CCLabel label = CCLabel.makeLabel("callback 3 called", "DroidSans", 16);
label.setPosition(CGPoint.ccp(s.width / 4 * 3, s.height / 2));
addChild(label);
}
public String title() {
return "Sequence of InstantActions";
}
}
댓글
댓글 쓰기