//GameScene.h #include "cocos2d.h" class GameScene : public cocos2d::Layer { public: static cocos2d::Scene* createScene(); virtual bool init(); void menuCallback(cocos2d::Ref* pSender); CREATE_FUNC(GameScene); };
//GameScene.cpp #include "GameScene.h" USING_NS_CC; cocos2d::Scene* GameScene::createScene() { auto scene = Scene::create(); //创建一个场景 auto layer = GameScene::create(); //创建一个图层 scene->addChild(layer); return scene; } //初始化当前的图层 bool GameScene::init() { if(!Layer::init()) //初始化父类 return false; //获取屏幕大小 auto visibleSize = Director::getInstance()->getVisibleSize(); auto size = Director::getInstance()->getWinSize(); //床架网格节点 auto nodegrid = NodeGrid::create(); auto sprite = Sprite::create("OnePiece_1.png"); sprite->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2)); nodegrid->addChild(sprite); //这里注意是将精灵节点加到网格节点上 this->addChild(nodegrid); // //翻页效果 // Director::getInstance()->setDepthTest(true); //开启深度检测 // auto pageturn = PageTurn3D::create(2, Size(20, 18)); // nodegrid->runAction(pageturn); // // //震动效果 // auto shaky = Shaky3D::create(6, Size(2, 1), 5, false); // nodegrid->runAction(shaky); //翻转效果 auto flipX = FlipX3D::create(2); auto reFlipX = flipX->reverse(); auto delay = DelayTime::create(2); //延时2秒 nodegrid->runAction(Sequence::create(flipX, delay, reFlipX, NULL)); // //透镜效果 // auto lens = Lens3D::create(5, Size(20, 15), Vec2(size.width/2, size.height/2), 300); //参数依次为:持续时间、网格大小、中心坐标、半径 // nodegrid->runAction(lens); // // //液体效果 // auto liquid = Liquid::create(3, Size(16, 12), 4, 10); //参数依次为:持续时间、网格大小、波纹数、振幅 // nodegrid->runAction(liquid); // // //波纹效果 // auto ripple = Ripple3D::create(5, Size(20, 16), Vec2(size.width/2, size.height/2), 300, 6, 50); // nodegrid->runAction(ripple); // // //波浪效果 // auto wave = Waves3D::create(5, Size(25, 20), 6, 30); // nodegrid->runAction(wave); return true; }
Cocos2d-x3.2 Grid3D网格动作,布布扣,bubuko.com
原文地址:http://my.oschina.net/Jacedy/blog/301575