2012-04-19 14:35:52 +08:00
|
|
|
#include "KeypadTest.h"
|
|
|
|
|
|
|
|
KeypadTest::KeypadTest()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
|
|
|
LabelTTF* label = LabelTTF::create("Keypad Test", "Arial", 28);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(label, 0);
|
|
|
|
label->setPosition( ccp(s.width/2, s.height-50) );
|
|
|
|
|
2012-06-15 15:10:40 +08:00
|
|
|
setKeypadEnabled(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// create a label to display the tip string
|
2013-06-20 14:17:10 +08:00
|
|
|
_label = LabelTTF::create("Please press any key...", "Arial", 22);
|
2013-06-15 14:03:30 +08:00
|
|
|
_label->setPosition(ccp(s.width / 2, s.height / 2));
|
|
|
|
addChild(_label, 0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_label->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
KeypadTest::~KeypadTest()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_label->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void KeypadTest::keyBackClicked()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_label->setString("BACK clicked!");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void KeypadTest::keyMenuClicked()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_label->setString("MENU clicked!");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void KeypadTestScene::runThisTest()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new KeypadTest();
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(pLayer);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(this);
|
2012-04-19 14:35:52 +08:00
|
|
|
pLayer->release();
|
|
|
|
}
|