//
Scene*HelloWorld::createScene()
{
autolayer =HelloWorld::
returnscene;
}
boolHelloWorld::init()
if( !Layer::init() )
SizevisibleSize =Director::getInstance()->getVisibleSize();//获得现实区域
//
//
//
//
autocloseItem =MenuItemImage::create(
"CloseSelected.png",255)">
closeItem->setPosition(Point(origin.x+ visibleSize.width- closeItem->getContentSize().width/2,255)">
automenu =Menu::create(closeItem,138)">NULL);
this->addChild(menu,138)">2);
autolabel =LabelTTF::create("Hello World","Arial",138)">24);
addChild(label,138)">1,138)">101);
//
//
//
//
//
//(移除事件监听器
//移除一个已经被添加了的监听器:
//_eventDispatcher->removeEventListener(listener);
//
//移除当前事件分发器中所有监听器:
//_eventDispatcher->removeAllEventListeners();
onTouchEnded=onTouchEnded,168)">onTouchMoved=onTouchMoved,138)">this);
voidHelloWorld::onTouchMoved(cocos2d::Touch*touch,Event*event){
boolHelloWorld::onTouchBegan(Touch* touch,0)">Event
{
}
//通过点击结束区域 来设置lable的位置
HelloWorld::onTouchEnded(autolocation = touch->getLocation();
s =getChildByTag(101);
floato = location.x- s->getPosition().x;
floata = location.y- s->y;
floatat = (float)CC_RADIANS_TO_DEGREES(atanf( o/a) );
if( a <0)
else
180-
RotateTo:: HelloWorld::menuCloseCallback(Ref* pSender)
automenuItem =static_cast(pSender);
"pSender-tag==%d",menuItem->getTag());
lambda 写法 挺有意思
获得现实的起点坐标
MessageBox("你点击了按钮!!",0)">提示");
NULL);
();
onTouchEnded= [](Event*event){
getLocation();
autotarget =static_cast
(event->getCurrentTarget()); autos = target->getChildByTag(
onTouchMoved= [](
事件调度器
}