背景
来源:互联网 发布:大鱼海棠制作软件 编辑:程序博客网 时间:2024/04/28 04:54
新建工程,testGround
修改HelloWorldScene.h
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class HelloWorld :public cocos2d::CCLayer
{
public:
// Method 'init' in cocos2d-x returns bool, instead of 'id' in cocos2d-iphone (an object pointer)
virtual bool init();
// there's no 'id' in cpp, so we recommend to return the class instance pointer
static cocos2d::CCScene* scene();
// preprocessor macro for "static create()" constructor ( node() deprecated )
CREATE_FUNC(HelloWorld);
};
#endif // __HELLOWORLD_SCENE_H__
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
// 'layer' is an autorelease object
HelloWorld *layer =HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSprite *spFont=CCSprite::create("front.png");
CCSprite *spMiddle=CCSprite::create("middle.png");
CCSprite *spFar=CCSprite::create("far.png");
CCParallaxNode *parallaxNode=CCParallaxNode::create();
addChild(parallaxNode);
//近景
parallaxNode->addChild(spFont,3, ccp(4.8f,0),ccp(spFont->getContentSize().width*0.5,spFont->getContentSize().height*0.5));
//中景
parallaxNode->addChild(spMiddle,2, ccp(1.6f,0),ccp(spMiddle->getContentSize().width*0.5,spMiddle->getContentSize().height*0.5+spFont->getContentSize().height*0.5));
//远景
parallaxNode->addChild(spFar,1, ccp(0.5f,0),ccp(spFar->getContentSize().width*0.5,spFar->getContentSize().height*0.5+spMiddle->getContentSize().height*0.5+spFont->getContentSize().height*0.5));
CCActionInterval *go=CCMoveBy::create(8,ccp(-200,0));
CCActionInterval *goBack=go->reverse();
CCFiniteTimeAction *seq=CCSequence::create(go,goBack,NULL);
parallaxNode->runAction(CCRepeatForever::create((CCActionInterval *) seq));
return true;
}
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- 背景
- UISearchBar背景透明,去掉背景,自定义背景
- UISearchBar背景透明,去掉背景,自定义背景
- UIsearchBar背景透明,去掉背景,自定义背景
- UISearchBar背景透明,去掉背景,自定义背景
- 纯CSS打造隔行变色表格
- linux 将标准输出重定向到本地缓存的实现
- Eclipse 注释模板设置
- Demystifying iOS Application Crash Logs
- 使用subversion管理iOS源代码
- 背景
- flex AdvancedDataGrid表格联动
- Android 中的AIDL简单实例[转载]
- struts2与ActionContext
- S3C2410 UART 的驱动实例
- div命名规范
- 使用github管理Eclipse分布式项目开发
- springMVC_国际化
- Linux下查看文件和文件夹大小的df和du命令