listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
CC_CALLBACK_0
CC_CALLBACK_1
CC_CALLBACK_2
CC_CALLBACK_3HelloWorld::onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
#pragma execution_character_set("utf-8")
#include "HelloWorldScene.h"
USING_NS_CC;
Scene* HelloWorld::createScene()
{
auto scene = Scene::create();
auto layer = HelloWorld::create();
scene->addChild(layer);
return scene;
}
bool HelloWorld::init()
{
if (!Layer::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
Director::getInstance()->setDisplayStats(false); // stats OFF
count = 0;
label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 96);
label->setPosition(Vec2(origin.x + 50, origin.y + 50));
label->setAnchorPoint(Vec2(0, 0));
this->addChild(label, 1);
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
bool HelloWorld::onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event)
{
auto str = String::create("No, ");
str->appendWithFormat("%i", count++);
label->setString(str->getCString());
return true;
}
| << 前へ | 次へ >> |