[SOLVED] Particle system create( ) call makes background disappear and nothing visible

Hi All,

I am using cocos2dx version:
C:>cocos -v
cocos2d-x-3.17.2
Cocos Console 2.3

Dev environment - Android Studio.
I am trying to use a particle system, but as soon as i use the create( ) call the background becomes black.

To be precise, i saw the screen goes pitch black as soon as i call:

auto emitter = ParticleFireworks::create();

Below is my code - any help is really appreciated.

// on “init” you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}

auto visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();

auto backgroundSprite = Sprite::create(“city1.png”);
backgroundSprite -> setPosition(origin.x + visibleSize.width / 2 , origin.y + visibleSize.height/2);
this->addChild(backgroundSprite, 1);

// Below create call makes background black, even if i comment rest of the code
auto emitter = ParticleFireworks::create();

// set the duration
emitter->setDuration(ParticleSystem::DURATION_INFINITY);

// radius mode
emitter->setEmitterMode(ParticleSystem::Mode::RADIUS);

// radius mode: 100 pixels from center
emitter->setStartRadius(10);
emitter->setStartRadiusVar(0);
emitter->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
emitter->setEndRadiusVar(0); // not used when start == end

emitter->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height/2));
emitter->setAnchorPoint(Vec2(0.5f, 0.5f));
this->addChild(emitter, 0);
return true;
}

Ok, so the issue is resolved when i disabled host GPU in emulator. I was using Nexus5 Android emulator, which doesnt give the option to disable Host GPU, so switched to Nexus 4.

Followed these links and it resolved:

Below link, since i didnt get option to disable host GPU in Nexus 5 emulator.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.