2012-04-19 14:35:52 +08:00
|
|
|
#include "KeypadTest.h"
|
|
|
|
|
|
|
|
KeypadTest::KeypadTest()
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF* label = CCLabelTTF::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-15 14:03:30 +08:00
|
|
|
_label = CCLabelTTF::create("Please press any key...", "Arial", 22);
|
|
|
|
_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()
|
|
|
|
{
|
|
|
|
CCLayer* pLayer = new KeypadTest();
|
|
|
|
addChild(pLayer);
|
|
|
|
|
|
|
|
CCDirector::sharedDirector()->replaceScene(this);
|
|
|
|
pLayer->release();
|
|
|
|
}
|