吧友帮我看看我这个怎么触屏不响应
cocos2d吧
全部回复
仅看楼主
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
level 2
updatsoul 楼主
//
// Created by mxdy on 14-1-7.
//
//
#ifndef __FlyCoCo__GameLayer__
#define __FlyCoCo__GameLayer__
#include <iostream>
#include "BasicLayer.h"
#include "HeroLayer.h"
USING_NS_CC;
class GameLayer:public BasicLayer{
public:
GameLayer();
~GameLayer();
static CCScene* scene();
virtual bool init();
CREATE_FUNC( GameLayer );
virtual void onEnter();
virtual void bg_scroll_callback(float t);
private:
HeroLayer* herolayer;
};
#endif /* defined(__FlyCoCo__GameLayer__) */
2014年02月13日 02点02分 3
1