Cocos2d-x3.2 Grid3D网格动作
前端之家收集整理的这篇文章主要介绍了
Cocos2d-x3.2 Grid3D网格动作,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//GameScene.h
#include"cocos2d.h"
class
GameScene:
public
cocos2d::Layer
{
:
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();
layer=GameScene::create();
scene->addChild(layer);
return
scene;
@H_
502_116@}
//初始化当前的图层
GameScene::init()
{
if
(!Layer::init())
return
false
;
visibleSize=Director::getInstance()->getVisibleSize();
size=Director::getInstance()->getWinSize();
//创建网格节点
nodegrid=NodeGrid::create();
sprite=Sprite::create(
"OnePiece_1.png"
);
sprite->setPosition(Vec2(visibleSize.width/2,visibleSize.height/2));
nodegrid->addChild(sprite);
this
->addChild(nodegrid);
Director::getInstance()->setDepthTest(
);
//Director::getInstance()->setDepthTest(true);//开启深度检测
//autopageturn=PageTurn3D::create(2,Size(20,18));
//nodegrid->runAction(pageturn);
//
//autoshaky=Shaky3D::create(6,Size(2,1),5,false);
//nodegrid->runAction(shaky);
//
//autoflipX=FlipX3D::create(2);
//autoreFlipX=flipX->reverse();
//autodelay=DelayTime::create(2);//延时2秒
//nodegrid->runAction(Sequence::create(flipX,delay,reFlipX,NULL));
lens=Lens3D::create(5,Size(32,24),Vec2(size.width/2,size.height/2),300);
nodegrid->runAction(lens);
//autoliquid=Liquid::create(3,Size(16,12),4,10);//参数依次为:持续时间、网格大小、波纹数、振幅
//nodegrid->runAction(liquid);
//
//autoripple=Ripple3D::create(5,16),300,6,50);
//nodegrid->runAction(ripple);
//
//autowave=Waves3D::create(5,Size(25,20),30);
//nodegrid->runAction(wave);
true
;
}