//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( false ); //使用网格之前需要取消OpenGL的深度测试
// //翻页效果
// 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(32, 24), 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 ;
}
|