// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...
	
	CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("hero/Hero.ExportJson");
	CCArmature* armature = CCArmature::create("Hero");
	armature->getAnimation()->play("attack");
	armature->setScale(1.5);
	armature->setPosition(ccp(visibleSize.width*0.25, visibleSize.height*0.25));

	addChild(armature);
    
    return true;
}
Exemplo n.º 2
0
bool MainMenuScene::init()
{    
	menuLayer = CCLayer::create();
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    // Add backgrounbdPic
    CCSprite* backGroundPic = CCSprite::create("pictures/mainMenuBackGround.png");
    backGroundPic->setAnchorPoint(ccp(0, 0));
    
    menuLayer->addChild(backGroundPic,0);
	
	// Add ChenXiaoG welcome armature
	CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("animations/ChenXiaoGeWelcome.ExportJson");
	CCArmature *armature = CCArmature::create("ChenXiaoGeWelcome");
	armature->getAnimation()->play("Animation1");
	armature->getAnimation()->setSpeedScale(1.5f);
	armature->setAnchorPoint(ccp(0,0));
	armature->setPosition(ccp(size.width/8, size.height/6));
	armature->setScale(0.5);
	menuLayer->addChild(armature,1);

    
    //Add StartBtn
    CCSprite* start     = CCSprite::create("pictures/startbtn.png");
    CCSprite* startPush = CCSprite::create("pictures/startbtnPush.png");
    
    CCMenuItemSprite * startBtn = CCMenuItemSprite::create(start, startPush, this, menu_selector(MainMenuScene::startBtnCallFunc));
    
    //Add Menu
    mainMenu = CCMenu::create(startBtn, NULL);
    mainMenu->setAnchorPoint(ccp(0, 0));
    mainMenu->setPosition(ccp(size.width/6, size.height/1.3));
    menuLayer->addChild(mainMenu,2);

	//Add snow particle
	CCParticleSystem *particle = CCParticleSnow::create();
	particle->setTexture(CCTextureCache::sharedTextureCache()->addImage("pictures/snow.png"));
	menuLayer->addChild(particle,3);

    this->addChild(menuLayer ,0);

    return true;
}