Example #1
0
void BlockManager::loadResource()
{
    CHAR szTemp[128] = {0};
    CCAnimation* Ani = new CCAnimation;

    m_pBgaSprite = CCSprite::spriteWithTexture(ResourceManager::sharedManager()->getMap(67));
    m_pBgaSprite->setAnchorPoint(ccp(0,0));
    m_pBgaSprite->setPosition(ccp(-1000,-1000));
    m_pGround->addChild(m_pBgaSprite);

    Ani->initWithName("TILE");

    for(int i=0; i<6; i++)
    {
        sprintf_s(szTemp, "Tile/Tile_Ground_%d.png",i);
        Ani->addFrameWithFileName(szTemp);
    }

    m_pBlockSprite = new CCSprite;
    m_pBlockSprite->init();
    m_pBlockSprite->setAnchorPoint(ccp(0,0));
    m_pBlockSprite->addAnimation(Ani);
    m_pBlockSprite->setIsVisible(false);
    m_pBlockSprite->setPosition(ccp(-1000,-1000));
    m_pGround->addChild(m_pBlockSprite);

    m_bLoaded = true;
    m_bLook	 = false;

    m_pBlock = new Object_block;
    m_pBlock->initWithBlock();
}
Example #2
0
//------------------------------------------------------------------
//
// ActionAnimate
//
//------------------------------------------------------------------
void ActionAnimate::onEnter()
{
    ActionsDemo::onEnter();

    centerSprites(1);

    CCAnimation* animation = CCAnimation::animationWithName("dance", 0.2f);
    char frameName[100] = {0};
    for( int i=1; i<15; i++)
    {
        sprintf(frameName, "Images/grossini_dance_%02d.png", i);
        animation->addFrameWithFileName(frameName);
    }

    CCActionInterval*  action = CCAnimate::actionWithAnimation( animation, false);
    CCActionInterval*  action_back = action->reverse();

    m_grossini->runAction( CCSequence::actions( action, action_back, NULL));
}
bool IntroLayer::init()
{
	bool pRet = false;
	if (CCLayer::init())
	{
		// Accept touch input
		this->setIsTouchEnabled(true);
		
		hasBeenSkipped = false;

		// Create the intro image
		CCSprite *introImage = CCSprite::spriteWithFile("Menus/Intro/intro1.png");
		introImage->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
		this->addChild(introImage);

		// Create the intro animation, and load it from intro1 to intro7.png
		CCAnimation *introAnimation = CCAnimation::animation();
        introAnimation->setDelay(3.5f);

		char frameName[100] = {0};

		for (int frameNumber=1; frameNumber < 8; frameNumber++) 
		{
			CCLOG("Adding image intro%d.png to the introAnimation.",frameNumber);
			sprintf(frameName, "Menus/Intro/intro%d.png", frameNumber);
			introAnimation->addFrameWithFileName(frameName);
		}

		// Create the actions to play the intro
		CCFiniteTimeAction *animationAction = CCAnimate::actionWithAnimation(introAnimation, false);
		CCFiniteTimeAction *startGameAction = CCCallFunc::actionWithTarget(this, callfunc_selector(IntroLayer::startGamePlay));
		CCFiniteTimeAction *introSequence = CCSequence::actions(animationAction, startGameAction, NULL);
		
		introImage->runAction(introSequence);
		pRet = true;
	}

	return pRet;
}