真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

cocos2d場景切換-創(chuàng)新互聯(lián)

開始學(xué)習(xí)cocos2d啦,加油?。。?!

站在用戶的角度思考問題,與客戶深入溝通,找到沅陵網(wǎng)站設(shè)計(jì)與沅陵網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站建設(shè)、外貿(mào)營銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋沅陵地區(qū)。

第一個(gè)hello world界面

#ifndef __HELLOWORLD_SCENE_H__

#define __HELLOWORLD_SCENE_H__

#include "cocos2d.h"

#include "SimpleAudioEngine.h"

class HelloWorld : public cocos2d::CCLayer

{

public:

  // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone

  virtual bool init();

  // there's no 'id' in cpp, so we recommand to return the exactly class pointer

  static cocos2d::CCScene* scene();

  // a selector callback

  void menuCloseCallback(CCObject* pSender);

  // implement the "static node()" method manually

  CREATE_FUNC(HelloWorld);

};

#endif  // __HELLOWORLD_SCENE_H__

#include "HelloWorldScene.h"

#include "MyLayer.h"

using namespace cocos2d;

CCScene* HelloWorld::scene()

{

  CCScene * scene = NULL;

  do

  {

    // 'scene' is an autorelease object

    scene = CCScene::create();

    CC_BREAK_IF(! scene);

    // 'layer' is an autorelease object

    HelloWorld *layer = HelloWorld::create();

    CC_BREAK_IF(! layer);

    // add layer as a child to scene

    scene->addChild(layer);

  } while (0);

  // return the scene

  return scene;

}

// on "init" you need to initialize your instance

bool HelloWorld::init()

{

  bool bRet = false;

  do

  {

    //////////////////////////////////////////////////////////////////////////

    // super init first

    //////////////////////////////////////////////////////////////////////////

    CC_BREAK_IF(! CCLayer::init());

    //////////////////////////////////////////////////////////////////////////

    // add your codes below...

    //////////////////////////////////////////////////////////////////////////

    // 1. Add a menu item with "X" p_w_picpath, which is clicked to quit the program.

    // Create a "close" menu item with close icon, it's an auto release object.

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(

      "CloseNormal.png",

      "CloseSelected.png",

      this,

      menu_selector(HelloWorld::menuCloseCallback));

    CC_BREAK_IF(! pCloseItem);

    // Place the menu item bottom-right conner.

    pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));

    // Create a menu with the "close" menu item, it's an auto release object.

    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);

    pMenu->setPosition(CCPointZero);

    CC_BREAK_IF(! pMenu);

    // Add the menu to HelloWorld layer as a child layer.

    this->addChild(pMenu, 1);

    // 2. Add a label shows "Hello World".

    // Create a label and initialize with string "Hello World".

    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);

    CC_BREAK_IF(! pLabel);

    // Get window size and place the label upper.

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    pLabel->setPosition(ccp(size.width / 2, size.height - 50));

    // Add the label to HelloWorld layer as a child layer.

    this->addChild(pLabel, 1);

    // 3. Add add a splash screen, show the cocos2d splash p_w_picpath.

    CCSprite* pSprite = CCSprite::create("HelloWorld.png");

    CC_BREAK_IF(! pSprite);

    // Place the sprite on the center of the screen

    pSprite->setPosition(ccp(size.width/2, size.height/2));

    // Add the sprite to HelloWorld layer as a child layer.

    this->addChild(pSprite, 0);

    bRet = true;

  } while (0);

  return bRet;

}

void HelloWorld::menuCloseCallback(CCObject* pSender)

{

  // "close" menu item clicked

  // CCDirector::sharedDirector()->end();

//場景切換

CCDirector::sharedDirector()->replaceScene(CCTransitionSlideInT::create(3.0,CMyLayer::scence()));

}

第二個(gè)場景代碼

#pragma once

#include "cocos2d.h"

using namespace cocos2d;

class CMyLayer:public CCLayer

{

public:

CMyLayer(void);

~CMyLayer(void);

static CCScene * scence();

virtual bool init();

void CMyLayer::menuCloseCallback(CCObject* pSender);

CREATE_FUNC(CMyLayer);

};

#include "MyLayer.h"

CMyLayer::CMyLayer(void)

{

}

CMyLayer::~CMyLayer(void)

{

}

 CCScene *CMyLayer:: scence()

{

CCScene *pScence = CCScene::create();

CMyLayer *pCMyLayer = CMyLayer::create();

pScence->addChild(pCMyLayer);

return pScence;

}

bool CMyLayer::  init()

{

CCLabelTTF *pLable = CCLabelTTF::create("HI Fighting..!!!","Arial",40);

pLable->setPosition(ccp(200,200));

this->addChild(pLable);

CCMenuItemImage *pCloseItem = CCMenuItemImage::create(

"CloseNormal.png",

"CloseSelected.png",

this,

menu_selector(CMyLayer::menuCloseCallback));

//CC_BREAK_IF(! pCloseItem);

// Place the menu item bottom-right conner.

pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));

// Create a menu with the "close" menu item, it's an auto release object.

CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);

pMenu->setPosition(CCPointZero);

 this->addChild(pMenu, 1);

//CC_BREAK_IF(! pMenu);

return true;

}

void CMyLayer::menuCloseCallback(CCObject* pSender)

{

// "close" menu item clicked

CCDirector::sharedDirector()->end();

//CCDirector::sharedDirector()->replaceScene(CMyLayer::scence());

}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


分享題目:cocos2d場景切換-創(chuàng)新互聯(lián)
本文網(wǎng)址:http://weahome.cn/article/dpjgdg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部