mirror of https://github.com/axmolengine/axmol.git
Merge branch 'master' of https://github.com/cocos2d/cocos2d-x
This commit is contained in:
commit
ca8dc4bc07
|
@ -41,6 +41,9 @@ public:
|
||||||
|
|
||||||
// The back key clicked
|
// The back key clicked
|
||||||
virtual void keyBackClicked() {}
|
virtual void keyBackClicked() {}
|
||||||
|
|
||||||
|
// The menu key clicked. only avialble on uphone & android
|
||||||
|
virtual void keyMenuClicked() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace cocos2d {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
// the back key clicked msg
|
// the back key clicked msg
|
||||||
kTypeBackClicked = 1,
|
kTypeBackClicked = 1,
|
||||||
|
kTypeMenuClicked,
|
||||||
} ccKeypadMSGType;
|
} ccKeypadMSGType;
|
||||||
|
|
||||||
struct _ccCArray;
|
struct _ccCArray;
|
||||||
|
|
|
@ -29,10 +29,10 @@ THE SOFTWARE.
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
static CCKeypadDispatcher* s_KeypadDispatcher = NULL;
|
static CCKeypadDispatcher* s_KeypadDispatcher = NULL;
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// CCKeypadDispatcher
|
// CCKeypadDispatcher
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
CCKeypadDispatcher::CCKeypadDispatcher()
|
CCKeypadDispatcher::CCKeypadDispatcher()
|
||||||
: m_bLocked(false)
|
: m_bLocked(false)
|
||||||
|
@ -154,7 +154,9 @@ bool CCKeypadDispatcher::dispatchKeypadMSG(ccKeypadMSGType nMsgType)
|
||||||
case kTypeBackClicked:
|
case kTypeBackClicked:
|
||||||
pDelegate->keyBackClicked();
|
pDelegate->keyBackClicked();
|
||||||
break;
|
break;
|
||||||
|
case kTypeMenuClicked:
|
||||||
|
pDelegate->keyMenuClicked();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,11 @@ Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent)
|
||||||
{
|
{
|
||||||
bHandled = CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
|
bHandled = CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
|
||||||
}
|
}
|
||||||
|
else if (pEvent->sParam1 == SYS_KEY_SOFTKEY_LEFT_UP ||
|
||||||
|
pEvent->sParam1 == SYS_KEY_SOFTKEY_LEFT_LONG)
|
||||||
|
{
|
||||||
|
bHandled == CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeMenuClicked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,45 @@
|
||||||
#include "KeypadTest.h"
|
#include "KeypadTest.h"
|
||||||
|
|
||||||
KeypadTest::KeypadTest()
|
KeypadTest::KeypadTest()
|
||||||
: m_bShow(true)
|
: m_bShow(true)
|
||||||
{
|
{
|
||||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
CCLabel* label = CCLabel::labelWithString("Keypad Test", "Arial", 28);
|
CCLabel* label = CCLabel::labelWithString("Keypad Test", "Arial", 28);
|
||||||
addChild(label, 0);
|
addChild(label, 0);
|
||||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||||
|
|
||||||
CCLabel* subtitle = CCLabel::labelWithString("only goes well in cocos2d-uphone now!", "Arial", 18);
|
CCLabel* subtitle = CCLabel::labelWithString("only goes well in cocos2d-uphone now!", "Arial", 18);
|
||||||
addChild(subtitle, 0);
|
addChild(subtitle, 0);
|
||||||
subtitle->setPosition( ccp(s.width/2, s.height-100) );
|
subtitle->setPosition( ccp(s.width/2, s.height-100) );
|
||||||
|
|
||||||
setIsKeypadEnabled(true);
|
setIsKeypadEnabled(true);
|
||||||
|
|
||||||
// create a label to display the tip string
|
// create a label to display the tip string
|
||||||
m_pLabel = CCLabel::labelWithString("Key Back Clicked!", "Arial", 22);
|
m_pLabel = CCLabel::labelWithString("Please press any key...", "Arial", 22);
|
||||||
m_pLabel->setPosition(ccp(s.width / 2, s.height / 2));
|
m_pLabel->setPosition(ccp(s.width / 2, s.height / 2));
|
||||||
addChild(m_pLabel, 0);
|
addChild(m_pLabel, 0);
|
||||||
m_pLabel->setIsVisible(false);
|
// m_pLabel->setIsVisible(false);
|
||||||
m_pLabel->retain();
|
m_pLabel->retain();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeypadTest::~KeypadTest()
|
KeypadTest::~KeypadTest()
|
||||||
{
|
{
|
||||||
m_pLabel->release();
|
m_pLabel->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeypadTest::keyBackClicked()
|
void KeypadTest::keyBackClicked()
|
||||||
{
|
{
|
||||||
m_pLabel->setIsVisible(m_bShow);
|
m_pLabel->setString("BACK clicked!");
|
||||||
m_bShow = !m_bShow;
|
// m_pLabel->setIsVisible(m_bShow);
|
||||||
}
|
// m_bShow = !m_bShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeypadTest::keyMenuClicked()
|
||||||
|
{
|
||||||
|
m_pLabel->setString("MENU clicked!");
|
||||||
|
// m_pLabel->setIsVisible(m_bShow);
|
||||||
|
// m_bShow = !m_bShow;
|
||||||
|
}
|
||||||
|
|
||||||
void KeypadTestScene::runThisTest()
|
void KeypadTestScene::runThisTest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,26 +1,27 @@
|
||||||
#ifndef _KEYPAD_TEST_H_
|
#ifndef _KEYPAD_TEST_H_
|
||||||
#define _KEYPAD_TEST_H_
|
#define _KEYPAD_TEST_H_
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "../testBasic.h"
|
#include "../testBasic.h"
|
||||||
|
|
||||||
class KeypadTest : public CCLayer
|
class KeypadTest : public CCLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeypadTest();
|
KeypadTest();
|
||||||
~KeypadTest();
|
~KeypadTest();
|
||||||
|
|
||||||
virtual void keyBackClicked();
|
virtual void keyBackClicked();
|
||||||
|
virtual void keyMenuClicked();
|
||||||
private:
|
|
||||||
CCLabel* m_pLabel;
|
private:
|
||||||
bool m_bShow;
|
CCLabel* m_pLabel;
|
||||||
};
|
bool m_bShow;
|
||||||
|
};
|
||||||
class KeypadTestScene : public TestScene
|
|
||||||
{
|
class KeypadTestScene : public TestScene
|
||||||
public:
|
{
|
||||||
virtual void runThisTest();
|
public:
|
||||||
};
|
virtual void runThisTest();
|
||||||
|
};
|
||||||
#endif
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue