Esempio n. 1
0
ProjectileController* ProjectileController::create(void)
{
    ProjectileController * pRet = new (std::nothrow) ProjectileController();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
	return pRet;
}
void PlayerController::ccTouchesEnded(Set *pTouches, Event *pEvent)
{
    // Choose one of the touches to work with
	Touch* touch = (Touch*)( pTouches->anyObject() );
	Point location = touch->getLocation();
    

	Sprite *projectile = Sprite::create("components/Projectile.png", CCRectMake(0, 0, 20, 20));
    _owner->getParent()->addChild(projectile, 1, 4);
    
    ProjectileController *com = ProjectileController::create();
    projectile->addComponent(com);
    com->move(location.x, location.y);

    ((ComAudio*)(_owner->getComponent("Audio")))->playEffect("pew-pew-lei.wav");
}
Esempio n. 3
0
void PlayerController::onTouchesEnded(const std::vector<Touch*>& touches, Event  *event)
{
    // Choose one of the touches to work with
	Touch* touch = touches[0];
	Point location = touch->getLocation();
    

	Sprite *projectile = Sprite::create("components/Projectile.png", Rect(0, 0, 20, 20));
    _owner->getParent()->addChild(projectile, 1, 4);
    
    ProjectileController *com = ProjectileController::create();
    projectile->addComponent(com);
    com->move(location.x, location.y);

    ((ComAudio*)(_owner->getComponent("Audio")))->playEffect("pew-pew-lei.wav");
}