2011-07-08 11:22:35 +08:00
|
|
|
//
|
|
|
|
// Bug-624
|
|
|
|
// http://code.google.com/p/cocos2d-iphone/issues/detail?id=624
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Bug-624.h"
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Bug624Layer
|
|
|
|
//
|
2011-07-08 11:22:35 +08:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
bool Bug624Layer::init()
|
|
|
|
{
|
|
|
|
if(BugsTestBaseLayer::init())
|
|
|
|
{
|
|
|
|
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("Layer1", "Marker Felt", 36);
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
label->setPosition(ccp(size.width/2, size.height/2));
|
|
|
|
addChild(label);
|
2012-06-15 15:10:40 +08:00
|
|
|
setAccelerometerEnabled(true);
|
2011-07-08 11:22:35 +08:00
|
|
|
schedule(schedule_selector(Bug624Layer::switchLayer), 5.0f);
|
|
|
|
|
|
|
|
return true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return false;
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void Bug624Layer::switchLayer(float dt)
|
2011-07-08 11:22:35 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
unschedule(schedule_selector(Bug624Layer::switchLayer));
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCScene *scene = CCScene::create();
|
|
|
|
scene->addChild(Bug624Layer2::create(), 0);
|
|
|
|
CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(2.0f, scene, ccWHITE));
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Bug624Layer::didAccelerate(CCAcceleration* acceleration)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLog("Layer1 accel");
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Bug624Layer2
|
|
|
|
//
|
2011-07-08 11:22:35 +08:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
bool Bug624Layer2::init()
|
|
|
|
{
|
|
|
|
if(BugsTestBaseLayer::init())
|
|
|
|
{
|
|
|
|
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("Layer2", "Marker Felt", 36);
|
2011-07-08 11:22:35 +08:00
|
|
|
|
|
|
|
label->setPosition(ccp(size.width/2, size.height/2));
|
|
|
|
addChild(label);
|
2012-06-15 15:10:40 +08:00
|
|
|
setAccelerometerEnabled(true);
|
2011-07-08 11:22:35 +08:00
|
|
|
schedule(schedule_selector(Bug624Layer2::switchLayer), 5.0f);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void Bug624Layer2::switchLayer(float dt)
|
2011-07-08 11:22:35 +08:00
|
|
|
{
|
|
|
|
unschedule(schedule_selector(Bug624Layer::switchLayer));
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCScene *scene = CCScene::create();
|
|
|
|
scene->addChild(Bug624Layer::create(), 0);
|
|
|
|
CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(2.0f, scene, ccRED));
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Bug624Layer2::didAccelerate(CCAcceleration* acceleration)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLog("Layer2 accel");
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|