level 2
updatsoul
楼主
bool HeroLayer::init(){
bool isinit = false;
do {
CC_BREAK_IF(!BasicLayer::init());
//创建主角
hero = CCSprite::create("hero.png");
hero->setAnchorPoint(ccp(0.5,0));
hero->setPosition(ccp(getWinSize().width / 2, getWinSize().height / 2));
this->addChild(hero);
this->setTouchEnabled(true);
isinit = true;
} while (0);
return isinit;
}
bool HeroLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent){
CCMoveTo* move_action = CCMoveTo::create(0.3f, pTouch->getLocation());
hero->runAction(move_action);
hero->setPosition( pTouch->getLocation());
return true;
}
void HeroLayer::registerWithTouchDispatcher(void){
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,INT_MIN+1,true);
}
2014年02月06日 17点02分
1
bool isinit = false;
do {
CC_BREAK_IF(!BasicLayer::init());
//创建主角
hero = CCSprite::create("hero.png");
hero->setAnchorPoint(ccp(0.5,0));
hero->setPosition(ccp(getWinSize().width / 2, getWinSize().height / 2));
this->addChild(hero);
this->setTouchEnabled(true);
isinit = true;
} while (0);
return isinit;
}
bool HeroLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent){
CCMoveTo* move_action = CCMoveTo::create(0.3f, pTouch->getLocation());
hero->runAction(move_action);
hero->setPosition( pTouch->getLocation());
return true;
}
void HeroLayer::registerWithTouchDispatcher(void){
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,INT_MIN+1,true);
}