摘要:CCSetIterator it = pTouches->begin(); CCTouch *touch = (CCTouch*)(*it); CCPoint m_tBeginPos = touch->getLocationInView(); m_tBeginPos = CCDirector::sharedDirector()->convertToGL(m_tBeginPos); CCAction *moveto = CCMoveTo::create(2, m_tBeginPos); player->runAction(moveto);
阅读全文
摘要:/* 申明数组的时候一定要注意retain:比如 _targets = CCArray::create(); _targets->retain();*/ voidHelloWorld::update(CCTime dt){ CCArray *projectilesToDelete = CCArray::create(); projectilesToDelete->retain(); for (int i = 0; i < _projectiles->count(); i++) { CCSprite *projectile = (CCSprite...
阅读全文
摘要:void HelloWorld::ccTouchesEnded(CCSet *touches,cocos2d::CCEvent *event){ CCTouch *touch = (CCTouch*)(touches->anyObject()); CCPoint location = touch->getLocationInView(); location = CCDirector::sharedDirector()->convertToGL(location); CCSize winSize = CCDirector::sharedDirector()->ge...
阅读全文
摘要:boolHelloWorld::init(){ if ( !CCLayer::init() ) { returnfalse; } glClearColor(255.0f, 255.0f, 255.0f, 1.0f);//背景颜色 CCSize size = CCDirector::sharedDirector()->getWinSize(); CCSprite *player = CCSprite::create("Player.png"); player->setPosition(ccp(player->getContentSize(...
阅读全文