2013-06-07 08:12:28 +08:00
|
|
|
//
|
|
|
|
// BaseTest.cpp
|
|
|
|
// TestCpp
|
|
|
|
//
|
|
|
|
// Created by Ricardo Quesada on 6/6/13.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "BaseTest.h"
|
|
|
|
#include "VisibleRect.h"
|
|
|
|
#include "testResource.h"
|
|
|
|
|
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
|
|
|
|
void BaseTest::onEnter()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnter();
|
2013-06-07 08:12:28 +08:00
|
|
|
|
|
|
|
// add title and subtitle
|
|
|
|
std::string str = title();
|
|
|
|
const char * pTitle = str.c_str();
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* label = LabelTTF::create(pTitle, "Arial", 32);
|
2013-07-07 21:08:14 +08:00
|
|
|
addChild(label, 9999);
|
2013-07-12 14:11:55 +08:00
|
|
|
label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 30) );
|
2013-06-07 08:12:28 +08:00
|
|
|
|
|
|
|
std::string strSubtitle = subtitle();
|
|
|
|
if( ! strSubtitle.empty() )
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* l = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
2013-07-07 21:08:14 +08:00
|
|
|
addChild(l, 9999);
|
2013-07-12 14:11:55 +08:00
|
|
|
l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
2013-06-07 08:12:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// add menu
|
2013-06-14 11:36:43 +08:00
|
|
|
// CC_CALLBACK_1 == std::bind( function_ptr, instance, std::placeholders::_1, ...)
|
2013-07-24 06:20:22 +08:00
|
|
|
MenuItemImage *item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(BaseTest::backCallback, this) );
|
|
|
|
MenuItemImage *item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(BaseTest::restartCallback, this) );
|
|
|
|
MenuItemImage *item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(BaseTest::nextCallback, this) );
|
2013-06-07 08:12:28 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Menu *menu = Menu::create(item1, item2, item3, NULL);
|
2013-06-07 08:12:28 +08:00
|
|
|
|
2013-07-12 14:47:36 +08:00
|
|
|
menu->setPosition(Point::ZERO);
|
2013-07-12 14:11:55 +08:00
|
|
|
item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item2->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item3->setPosition(Point(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
2013-06-07 08:12:28 +08:00
|
|
|
|
2013-07-07 21:08:14 +08:00
|
|
|
addChild(menu, 9999);
|
2013-06-07 08:12:28 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseTest::onExit()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onExit();
|
2013-06-07 08:12:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string BaseTest::title()
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string BaseTest::subtitle()
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2013-07-26 06:53:24 +08:00
|
|
|
void BaseTest::restartCallback(Object* sender)
|
2013-06-07 08:12:28 +08:00
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("override restart!");
|
2013-06-07 08:12:28 +08:00
|
|
|
}
|
|
|
|
|
2013-07-26 06:53:24 +08:00
|
|
|
void BaseTest::nextCallback(Object* sender)
|
2013-06-07 08:12:28 +08:00
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("override next!");
|
2013-06-07 08:12:28 +08:00
|
|
|
}
|
|
|
|
|
2013-07-26 06:53:24 +08:00
|
|
|
void BaseTest::backCallback(Object* sender)
|
2013-06-07 08:12:28 +08:00
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("override back!");
|
2013-06-07 08:12:28 +08:00
|
|
|
}
|