Cocos2d-x3.2 Ease加速度

//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;
    
    //获取屏幕大小
    Size visibleSize = Director::getInstance()->getVisibleSize();
    //auto size = Director::getInstance()->getWinSize();
    //添加一个图片精灵
    auto sprite1 = Sprite::create("Icon.png");
    sprite1->setPosition(Vec2(visibleSize.width*0.2, visibleSize.height*0.8));
    this->addChild(sprite1);
    
    auto sprite2 = Sprite::create("Icon.png");
    sprite2->setPosition(Vec2(visibleSize.width*0.2, visibleSize.height/2));
    this->addChild(sprite2);
    
    auto sprite3 = Sprite::create("Icon.png");
    sprite3->setPosition(Vec2(visibleSize.width*0.2, visibleSize.height*0.3));
    this->addChild(sprite3);
    
    //弹性缓冲
    sprite1->runAction(EaseElasticInOut::create(MoveTo::create(3, Vec2(visibleSize.width*0.8, visibleSize.height*0.8))));
    
//    //指数缓冲
//    sprite1->runAction(EaseExponentialInOut::create(MoveTo::create(3, Vec2(visibleSize.width*0.8, visibleSize.height/2))));
//    
//    //Sine缓冲
//    sprite1->runAction(EaseSineInOut::create(MoveTo::create(3, Vec2(visibleSize.width*0.8, visibleSize.height*0.3))));
    
    //回震缓冲
    sprite2->runAction(EaseBackInOut::create(ScaleTo::create(3, 2)));
    
    //跳跃缓冲
    sprite3->runAction(EaseBounceInOut::create(MoveTo::create(3, Vec2(visibleSize.width*0.8, visibleSize.height*0.3))));
    
    return true;
}

图示各种运动加速度:

Cocos2d-x3.2 Ease加速度_第1张图片

Cocos2d-x3.2 Ease加速度_第2张图片

Cocos2d-x3.2 Ease加速度_第3张图片

Cocos2d-x3.2 Ease加速度_第4张图片

Cocos2d-x3.2 Ease加速度_第5张图片


你可能感兴趣的:(Cocos2d-x3.2 Ease加速度)