2010-08-06 17:50:20 +08:00
|
|
|
#include "tests.h"
|
|
|
|
#include "controller.h"
|
2010-08-13 17:21:33 +08:00
|
|
|
#include "CCMenu.h"
|
2010-08-17 15:01:09 +08:00
|
|
|
#include "CCLabel.h"
|
2010-08-06 17:50:20 +08:00
|
|
|
#include "touch_dispatcher/CCTouchDispatcher.h"
|
|
|
|
|
|
|
|
TestController::TestController()
|
|
|
|
{
|
|
|
|
/**
|
2010-08-09 18:07:50 +08:00
|
|
|
@todo add menu items for all tests
|
2010-08-06 17:50:20 +08:00
|
|
|
*/
|
2010-08-17 15:01:09 +08:00
|
|
|
CCLabel* label = CCLabel::labelWithString("ActionsTest", "Arial", 22);
|
2010-08-13 17:21:33 +08:00
|
|
|
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(TestController::menuCallback));
|
2010-08-06 17:50:20 +08:00
|
|
|
|
2010-08-17 17:38:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
// add close menu
|
|
|
|
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage("/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/close.png",
|
|
|
|
"/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/close.png",
|
|
|
|
this, menu_selector(TestController::closeCallback) );
|
|
|
|
|
|
|
|
CCMenu* pMenu =CCMenu::menuWithItems(pMenuItem, pCloseItem, NULL);
|
2010-08-13 17:21:33 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
pMenu->setPosition( CGPointZero );
|
|
|
|
pMenuItem->setPosition( CGPointMake( s.width / 2, s.height / 2) );
|
2010-08-17 17:38:26 +08:00
|
|
|
pCloseItem->setPosition(CGPointMake( s.width - 30, s.height - 30));
|
2010-08-06 17:50:20 +08:00
|
|
|
|
2010-08-13 17:21:33 +08:00
|
|
|
addChild(pMenu, 1);
|
2010-08-06 17:50:20 +08:00
|
|
|
}
|
|
|
|
|
2010-08-13 17:21:33 +08:00
|
|
|
void TestController::menuCallback(NSObject * pSender)
|
2010-08-06 17:50:20 +08:00
|
|
|
{
|
|
|
|
TestScene* pScene = new ActionsTestScene();
|
|
|
|
|
|
|
|
pScene->runThisTest();
|
|
|
|
}
|
2010-08-17 17:38:26 +08:00
|
|
|
|
|
|
|
void TestController::closeCallback(NSObject * pSender)
|
|
|
|
{
|
|
|
|
TApplication * pApp = TApplication::GetCurrentApplication();
|
|
|
|
|
|
|
|
CCDirector::getSharedDirector()->end();
|
|
|
|
pApp->SendStopEvent();
|
|
|
|
}
|