建立一个英雄,应当设置大小如下:
this.setContentSize(CGSize.make(85, 90));
CCTouchDispatcher.sharedDispatcher().addTargetedDelegate(this, 1, true);
//this.setIsTouchEnabled(true);
// mao body
mao=CCSprite.sprite("catBody1.png");
CCAnimation animation = CCAnimation.animation("mao");
animation.addFrame("catBody1.png");
animation.addFrame("catBody2-4.png");
animation.addFrame("catBody3.png");
animation.addFrame("catBody2-4.png");
CCAnimate action = CCAnimate.action(3, animation, false);
CCAnimate action_back = action.reverse();
mao.runAction(CCRepeatForever.action(CCSequence.actions(action, action_back)));
addChild(mao,1);
//mao head
lefthand=CCSprite.sprite("catHand1.png");
lefthand.setAnchorPoint(CGPoint.ccp(1,(float) 0.5));
lefthand.setPosition(-18, -20);
addChild(lefthand,2);
righthand=CCSprite.sprite("catHand2.png");
righthand.setAnchorPoint(CGPoint.ccp(0,(float) 0.5));
righthand.setPosition(18, -20);
addChild(righthand,3);
//mao tail
tail = CCSprite.sprite("catTail.png");
tail.setAnchorPoint(CGPoint.ccp((float) 0.5,1));
tail.setPosition(CGPoint.ccp(-5,-29));
tail.setScale((float) 0.5);
tail.setRotation(20);
tail.runAction(CCRepeatForever.action(
CCSequence.actions(CCRotateBy.action((float) 0.5,-40),CCRotateBy.action((float) 0.5,40))));
addChild(tail,3);
offset = CGPoint.ccp(0,0);
iscontrol = false;
这样的坐标是对contentsize来设置的。