Exemplo n.º 1
0
void PauseLayer::initMenu()
{
    menuNode = CCNode::create();
    CCMenuItemSprite *resumeGame = BaseMenuSprite::createMenuSprite(SPRITE_FRAME(paused_resume_normal_china.png),SPRITE_FRAME(paused_resume_push_china.png),NULL,this,menu_selector(PauseLayer::resumeHandler),"sounds/SFX/buttonclick.mp3");
    CCMenuItemSprite *restartGame = BaseMenuSprite::createMenuSprite(SPRITE_FRAME(paused_restart_normal_china.png),SPRITE_FRAME(paused_restart_push_china.png),NULL,NULL,NULL,"sounds/SFX/buttonclick.mp3");
    CCMenuItemSprite *quitGame = BaseMenuSprite::createMenuSprite(SPRITE_FRAME(paused_quit_normal_china.png),SPRITE_FRAME(paused_quit_push_china.png),NULL,this,menu_selector(PauseLayer::quitHandler),"sounds/SFX/buttonclick.mp3");
    gameMenu = CCMenu::create(resumeGame,restartGame,quitGame,NULL);
    gameMenu->alignItemsVerticallyWithPadding(15);
    CCSprite *menuBg = SPRITE_FRAME(paused_bg.png);
    menuNode->setPosition(ccp(VisibleRect::center().x,-232));
    menuNode->addChild(menuBg);
    menuNode->addChild(gameMenu);
    gameMenu->setPosition(ccp(65,-60));
    CCActionInterval *moveAct = CCMoveTo::create(PAUSE_SLIDE_TIME,ccp(VisibleRect::center().x,232));
    menuNode->runAction(moveAct);
    addChild(menuNode);
}
Exemplo n.º 2
0
bool BoySprite::init() {
	char name[50] = {0};
	this->boyIndex = 1;
	// add the this->boyIndex if there are more than one boys
	sprintf(name, "run0000.png");
	if(Sprite::initWithSpriteFrame(SPRITE_FRAME(name))) {
		auto running = this->createAnimation("run00%02d.png",this->boyIndex, 15, 4);
		this->runningAction = RepeatForever::create(Animate::create(running));
		this->runningAction->setTag(ACTION_STATE_RUN_TAG);
		// void released by system
		this->runningAction->retain();

		auto slide = this->createAnimation("slide00%02d.png",this->boyIndex, 15, 4);
		this->slideAction = RepeatForever::create(Animate::create(slide));
		this->slideAction->setTag(ACTION_STATE_SLIDE_TAG);
		this->slideAction->retain();

		auto jumpUp = this->createAnimation("jump0100%02d.png",this->boyIndex, 10, 2);
		this->jumpUpAction = Animate::create(jumpUp);
		this->jumpUpAction->setTag(ACTION_STATE_JUMP_UP_TAG);
		this->jumpUpAction->retain();

		auto jumpDown = this->createAnimation("jump0200%0d.png",this->boyIndex, 12, 2);
		this->jumpDownAction = Animate::create(jumpDown);
		this->jumpDownAction->setTag(ACTION_STATE_JUMP_DOWN_TAG);
		this->jumpDownAction->retain();

		this->dieAction = RotateBy::create(0.1f, -45);
		dieAction->retain();

		this->setPhysical();

		return true;
	}else {
		return false;
	}
}