本文整理汇总了C++中MenuItemToggle::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemToggle::setAnchorPoint方法的具体用法?C++ MenuItemToggle::setAnchorPoint怎么用?C++ MenuItemToggle::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemToggle
的用法示例。
在下文中一共展示了MenuItemToggle::setAnchorPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool TestJoystick::init()
{
if(!Layer::init())
{
return false;
}
m_isFollow = true;
Vec2 visibleOrigin = Director::getInstance()->getVisibleOrigin();
Size visibleSize = Director::getInstance()->getVisibleSize();
Sprite* pSprite = Sprite::create("HelloWorld.png");
pSprite->setPosition(Vec2(visibleOrigin.x + visibleSize.width / 2.0f,
visibleOrigin.y + visibleSize.height / 2.0f));
this->addChild(pSprite, 0);
MenuItemToggle* toggle = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestJoystick::menuItemToggleCallback,this),
MenuItemFont::create("follow"),
MenuItemFont::create("normal"),
NULL);
toggle->setAnchorPoint(Vec2(0.5f,0.5f));
this->addChild(Menu::create(toggle,NULL),1);
m_ball = CCSprite::create("ball.png");
m_ball->setScale(0.5f);
m_ball->setPosition(Vec2(200.0f,200.0f));
this->addChild(m_ball,2);
//创建摇杆实
m_joystick = Joystick::create("joystickBg.png",70.0f,"joystickHandle.png",50.0f);
m_joystick->setPosition(Vec2(70.0f,70.0f));
m_joystick->setVisible(false);
//摇杆触碰事件的回调
m_joystick->setHandleEventListener(JOYSTICK_CALLBACK(TestJoystick::moveSpr,this));
//触碰在摇杆外部的回调,用于follow模式下的摇杆,如果该回调返回true,则以后将继续接收JET_TOUCH_BEGIN,JET_TOUCH_MOVE和JET_TOUCH_END消息
m_joystick->setTouchOutsideCallback(CC_CALLBACK_2(TestJoystick::touchOutsideHandle,this));
this->addChild(m_joystick,3);
return true;
}