Android Raywenderlich教程-太空游戏

Android Raywenderlich教程-太空游戏,android,c++,sprite,cocos2d-x,Android,C++,Sprite,Cocos2d X,您好,我正在跟随Raywenderlich的教程()使用Eclipse for Android平台在Cocos2d-x-2.2中创建空间游戏 我在“添加视差滚动”部分出现问题。复制粘贴代码后,我看不到背景精灵 .cpp文件 bool HelloWorld::init() { if ( !CCLayer::init() ) { return false; } CCSize visibleSize = CCDirector::sharedDirector()->getVisibleS

您好,我正在跟随Raywenderlich的教程()使用Eclipse for Android平台在Cocos2d-x-2.2中创建空间游戏

我在“添加视差滚动”部分出现问题。复制粘贴代码后,我看不到背景精灵

.cpp文件

bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
    return false;
}

CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

/////////////////////////////
_batchNode = CCSpriteBatchNode::create("Sprites.pvr.ccz");
this->addChild(_batchNode);
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Sprites.plist");

_ship = CCSprite::createWithSpriteFrameName("SpaceFlier_sm_1.png");
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
_ship->setPosition(ccp(winSize.width * 0.1, winSize.height * 0.5));
_batchNode->addChild(_ship, 1);
return true;

 // 1) Create the CCParallaxNode
_backgroundNode = CCParallaxNode::create();
this->addChild(_backgroundNode,-1);

// 2) Create the sprites will be added to the CCParallaxNode
_spacedust1 = CCSprite::create("bg_front_spacedust.png");
_spacedust2 = CCSprite::create("bg_front_spacedust.png");
_planetsunrise = CCSprite::create("bg_planetsunrise.png");
_galaxy = CCSprite::create("bg_galaxy.png");
_spacialanomaly = CCSprite::create("bg_spacialanomaly.png");
_spacialanomaly2 = CCSprite::create("bg_spacialanomaly2.png");

// 3) Determine relative movement speeds for space dust and background
CCPoint dustSpeed = ccp(0.1, 0.1);
CCPoint bgSpeed = ccp(0.05, 0.05);

// 4) Add children to CCParallaxNode
_backgroundNode->addChild(_spacedust1, 0, dustSpeed, ccp(0,winSize.height/2) ); 
_backgroundNode->addChild(_spacedust2, 0, dustSpeed, ccp( _spacedust1->getContentSize().width,winSize.height/2));
_backgroundNode->addChild(_galaxy, -1, bgSpeed, ccp(0, winSize.height * 0.7));
_backgroundNode->addChild(_planetsunrise, -1 , bgSpeed, ccp(600, winSize.height * 0));
_backgroundNode->addChild(_spacialanomaly, -1, bgSpeed, ccp(900, winSize.height * 0.3));
_backgroundNode->addChild(_spacialanomaly2, -1, bgSpeed, ccp(1500, winSize.height * 0.9));
this->scheduleUpdate();
}


void HelloWorld::update(float dt) {
CCPoint backgroundScrollVert = ccp(-1000, 0);
_backgroundNode->setPosition(ccpAdd(_backgroundNode->getPosition(), ccpMult(backgroundScrollVert, dt)));
}
.h文件

class HelloWorld : public cocos2d::CCLayer
{

private:
cocos2d::CCSpriteBatchNode * _batchNode;
cocos2d::CCSprite * _ship;
cocos2d::CCParallaxNode *_backgroundNode;
cocos2d::CCSprite *_spacedust1;
cocos2d::CCSprite *_spacedust2;
cocos2d::CCSprite *_planetsunrise;
cocos2d::CCSprite *_galaxy;
cocos2d::CCSprite *_spacialanomaly;
cocos2d::CCSprite *_spacialanomaly2;

// scheduled Update
void update(float dt);
我的实现中的错误在哪里?由于正在显示ship,资源被正确添加。

有:

return true; 

在代码中间。

您似乎没有任何渲染代码。您能告诉我更多关于它的信息吗?或者在教程中告诉我它在哪里?