本文整理汇总了C++中Sprite3D::setVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite3D::setVisible方法的具体用法?C++ Sprite3D::setVisible怎么用?C++ Sprite3D::setVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite3D
的用法示例。
在下文中一共展示了Sprite3D::setVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
// on "init" you need to initialize your instance
bool Sprite3DLesson5::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
auto closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(Sprite3DLesson5::menuCloseCallback, this));
closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
origin.y + closeItem->getContentSize().height/2));
// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DLesson5::onTouchesEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
/////////////////////////////
std::string filename = "res/Sprite3D/girl.c3b";
auto sprite = Sprite3D::create(filename);
sprite->setPosition(visibleSize.width/2 + origin.x, visibleSize.height/3 + origin.y);
addChild(sprite);
auto animation = Animation3D::create(filename);
auto animate = Animate3D::create(animation);
sprite->runAction(RepeatForever::create(animate));
auto lfoot = Sprite::create("res/Sprite3D/circle.png");
auto rfoot = Sprite::create("res/Sprite3D/circle.png");
_lfoot = Sprite3D::create();
_lfoot->addChild(lfoot);
_lfoot->setRotation3D(Vec3(90, 0, 0));
_rfoot = Sprite3D::create();
_rfoot->addChild(rfoot);
_rfoot->setRotation3D(Vec3(90, 0, 0));
addChild(_lfoot);
addChild(_rfoot);
_lfoot->setScale(0.3f);
_rfoot->setScale(0.3f);
_lfoot->setVisible(false);
_rfoot->setVisible(false);
_sprite = sprite;
ValueMap valuemap0;
valuemap0["footname"] = Value("Bip001 R Toe0");
valuemap0["lfoot"] = Value(false);
animate->setKeyFrameUserInfo(10, valuemap0);
valuemap0["footname"] = Value("Bip001 L Toe0");
valuemap0["lfoot"] = Value(true);
animate->setKeyFrameUserInfo(26, valuemap0);
auto listener2 = EventListenerCustom::create(Animate3DDisplayedNotification, [&](EventCustom* event)
{
auto info = (Animate3D::Animate3DDisplayedEventInfo*)event->getUserData();
auto footname = info->userInfo->at("footname").asString();
bool lfoot = info->userInfo->at("lfoot").asBool();
auto mat = _sprite->getNodeToWorldTransform() * _sprite->getSkeleton()->getBoneByName(footname)->getWorldMat();
Sprite3D* foot = lfoot ? _lfoot : _rfoot;
foot->setPosition3D(Vec3(mat.m[12], mat.m[13], mat.m[14]));
foot->setVisible(true);
cocos2d::log("frame %d", info->frame);
});
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(listener2, -1);
scheduleUpdate();
return true;
}