Friday, July 19, 2013

[android help] android screen goes black if I open cocos 2d project after getting out of an activity


android screen goes black if I open cocos 2d project after getting out of an activity



My android screen goes black if I open cocos 2d project after getting out of an activity



public static CCScene scene()
{

CCScene scene = CCScene.node();
CCLayer layer = new TemplateLayer();

scene.addChild(layer);

return scene;
}


this is my template layer


In this teplate I am adding several sprites and initializing update selector



protected TemplateLayer(ccColor4B color)
{

super(color);

sensorManager = (SensorManager) CCDirector.sharedDirector()
.getActivity().getSystemService(Context.SENSOR_SERVICE);

if (sensorManager != null)
{
orientation = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
}
else
{
orientation = null;
}

this.setIsTouchEnabled(true);

game = new GameActivity();

ball = CCSprite.sprite("rect.png");

x= winSize.width/8;
y= winSize.height/8;


ball.setAnchorPoint(CGPoint.ccp(0, 0));
ball.setPosition(CGPoint.ccp((float)x, (float)y));
addChild(ball);

killerchild = CCSprite.sprite("logo.png");
killerchild.setAnchorPoint(CGPoint.ccp(0, 0));

killerchild.setPosition(CGPoint.ccp(winSize.width/2-killerchild.getContentSize().width/2, winSize.height-killerchild.getContentSize().height));
addChild(killerchild);

boat = CCSprite.sprite("boat.png");
boat.setAnchorPoint(CGPoint.ccp(0, 0));

boat.setPosition(CGPoint.ccp(winSize.width/2-boat.getContentSize().width/2,-boat.getContentSize().height/4));
addChild(boat);


pirates = CCSprite.sprite("Pirates.png");
pirates.setAnchorPoint(CGPoint.ccp(0, 0));

pirates.setPosition(CGPoint.ccp(winSize.width/2-pirates.getContentSize().width/2,winSize.height/2-pirates.getContentSize().height/2));
addChild(pirates,-1);

this.schedule("update");


// this.schedule("moveboat", 0f);



}


Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...