2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2009 On-Core
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __ACTION_CCGRID3D_ACTION_H__
|
|
|
|
#define __ACTION_CCGRID3D_ACTION_H__
|
|
|
|
|
|
|
|
#include "CCActionGrid.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
2012-06-20 18:09:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup actions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief Waves3D action
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Waves3D : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates an action with duration, grid size, waves and amplitude */
|
|
|
|
static Waves3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
|
|
|
|
|
|
|
|
/** returns the amplitude of the effect */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitude() const { return _amplitude; }
|
2013-07-18 07:56:19 +08:00
|
|
|
/** sets the amplitude to the effect */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
/** returns the amplitude rate */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitudeRate() const { return _amplitudeRate; }
|
2013-07-18 07:56:19 +08:00
|
|
|
/** sets the ampliture rate */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual Waves3D* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-23 07:07:58 +08:00
|
|
|
Waves3D() {}
|
|
|
|
virtual ~Waves3D() {}
|
|
|
|
/** initializes an action with duration, grid size, waves and amplitude */
|
|
|
|
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int _waves;
|
|
|
|
float _amplitude;
|
|
|
|
float _amplitudeRate;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Waves3D);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief FlipX3D action */
|
|
|
|
class CC_DLL FlipX3D : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates the action with duration */
|
|
|
|
static FlipX3D* create(float duration);
|
|
|
|
|
2013-11-23 07:07:58 +08:00
|
|
|
// Override
|
|
|
|
virtual FlipX3D* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
FlipX3D() {}
|
|
|
|
virtual ~FlipX3D() {}
|
2012-04-19 14:35:52 +08:00
|
|
|
/** initializes the action with duration */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithDuration(float duration);
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual bool initWithSize(const Size& gridSize, float duration);
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-11-23 07:07:58 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(FlipX3D);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief FlipY3D action */
|
|
|
|
class CC_DLL FlipY3D : public FlipX3D
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-23 07:07:58 +08:00
|
|
|
FlipY3D() {}
|
|
|
|
virtual ~FlipY3D() {}
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action with duration */
|
2013-06-20 14:13:12 +08:00
|
|
|
static FlipY3D* create(float duration);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
|
|
|
// Overrides
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual FlipY3D* clone() const override;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(FlipY3D);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Lens3D action */
|
|
|
|
class CC_DLL Lens3D : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates the action with center position, radius, a grid size and duration */
|
|
|
|
static Lens3D* create(float duration, const Size& gridSize, const Point& position, float radius);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Get lens center position */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getLensEffect() const { return _lensEffect; }
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Set lens center position */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline void setLensEffect(float lensEffect) { _lensEffect = lensEffect; }
|
2013-02-16 11:12:12 +08:00
|
|
|
/** Set whether lens is concave */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline void setConcave(bool concave) { _concave = concave; }
|
2013-02-16 11:12:12 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline const Point& getPosition() const { return _position; }
|
2013-06-20 14:13:12 +08:00
|
|
|
void setPosition(const Point& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual Lens3D* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-23 07:07:58 +08:00
|
|
|
Lens3D() {}
|
|
|
|
virtual ~Lens3D() {}
|
|
|
|
/** initializes the action with center position, radius, a grid size and duration */
|
|
|
|
bool initWithDuration(float duration, const Size& gridSize, const Point& position, float radius);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/* lens center position */
|
2013-06-20 14:13:12 +08:00
|
|
|
Point _position;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _radius;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
|
2013-06-15 14:03:30 +08:00
|
|
|
float _lensEffect;
|
2013-02-16 11:12:12 +08:00
|
|
|
/** lens is concave. (true = concave, false = convex) default is convex i.e. false */
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _concave;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _dirty;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Lens3D);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Ripple3D action */
|
|
|
|
class CC_DLL Ripple3D : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates the action with radius, number of waves, amplitude, a grid size and duration */
|
|
|
|
static Ripple3D* create(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** get center position */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline const Point& getPosition() const { return _position; }
|
2012-04-19 14:35:52 +08:00
|
|
|
/** set center position */
|
2013-06-20 14:13:12 +08:00
|
|
|
void setPosition(const Point& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitude() const { return _amplitude; }
|
2013-06-15 14:03:30 +08:00
|
|
|
inline void setAmplitude(float fAmplitude) { _amplitude = fAmplitude; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitudeRate() const { return _amplitudeRate; }
|
2013-06-15 14:03:30 +08:00
|
|
|
inline void setAmplitudeRate(float fAmplitudeRate) { _amplitudeRate = fAmplitudeRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Override
|
|
|
|
virtual Ripple3D* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
2013-11-23 07:07:58 +08:00
|
|
|
Ripple3D() {}
|
|
|
|
virtual ~Ripple3D() {}
|
|
|
|
/** initializes the action with radius, number of waves, amplitude, a grid size and duration */
|
|
|
|
bool initWithDuration(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/* center position */
|
2013-06-20 14:13:12 +08:00
|
|
|
Point _position;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _radius;
|
|
|
|
unsigned int _waves;
|
|
|
|
float _amplitude;
|
|
|
|
float _amplitudeRate;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Ripple3D);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Shaky3D action */
|
|
|
|
class CC_DLL Shaky3D : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-23 07:07:58 +08:00
|
|
|
Shaky3D() {}
|
|
|
|
virtual ~Shaky3D() {}
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates the action with a range, shake Z vertices, a grid and duration */
|
|
|
|
static Shaky3D* create(float duration, const Size& gridSize, int range, bool shakeZ);
|
|
|
|
|
|
|
|
// Overrides
|
|
|
|
virtual Shaky3D* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
2013-11-23 07:07:58 +08:00
|
|
|
/** initializes the action with a range, shake Z vertices, a grid and duration */
|
|
|
|
bool initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
int _randrange;
|
|
|
|
bool _shakeZ;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Shaky3D);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Liquid action */
|
|
|
|
class CC_DLL Liquid : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-23 07:07:58 +08:00
|
|
|
Liquid() {}
|
|
|
|
virtual ~Liquid() {}
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates the action with amplitude, a grid and duration */
|
|
|
|
static Liquid* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
|
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitude() const { return _amplitude; }
|
|
|
|
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitudeRate() const { return _amplitudeRate; }
|
|
|
|
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual Liquid* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-23 07:07:58 +08:00
|
|
|
/** initializes the action with amplitude, a grid and duration */
|
|
|
|
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int _waves;
|
|
|
|
float _amplitude;
|
|
|
|
float _amplitudeRate;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Liquid);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Waves action */
|
|
|
|
class CC_DLL Waves : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-23 07:07:58 +08:00
|
|
|
Waves() {}
|
|
|
|
virtual ~Waves() {}
|
2013-07-18 07:56:19 +08:00
|
|
|
/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
|
|
|
|
static Waves* create(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
|
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitude() const { return _amplitude; }
|
|
|
|
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitudeRate() const { return _amplitudeRate; }
|
|
|
|
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual Waves* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-23 07:07:58 +08:00
|
|
|
/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
|
|
|
|
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int _waves;
|
|
|
|
float _amplitude;
|
|
|
|
float _amplitudeRate;
|
|
|
|
bool _vertical;
|
|
|
|
bool _horizontal;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Waves);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Twirl action */
|
|
|
|
class CC_DLL Twirl : public Grid3DAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-23 07:07:58 +08:00
|
|
|
Twirl() {}
|
|
|
|
virtual ~Twirl() {}
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates the action with center position, number of twirls, amplitude, a grid size and duration */
|
|
|
|
static Twirl* create(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** get twirl center */
|
2013-11-16 21:08:00 +08:00
|
|
|
inline const Point& getPosition() const { return _position; }
|
2012-04-19 14:35:52 +08:00
|
|
|
/** set twirl center */
|
2013-06-20 14:13:12 +08:00
|
|
|
void setPosition(const Point& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitude() const { return _amplitude; }
|
|
|
|
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
inline float getAmplitudeRate() const { return _amplitudeRate; }
|
|
|
|
inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual Twirl* clone() const override;
|
|
|
|
virtual void update(float time) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-23 07:07:58 +08:00
|
|
|
/** initializes the action with center position, number of twirls, amplitude, a grid size and duration */
|
|
|
|
bool initWithDuration(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/* twirl center */
|
2013-06-20 14:13:12 +08:00
|
|
|
Point _position;
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int _twirls;
|
|
|
|
float _amplitude;
|
|
|
|
float _amplitudeRate;
|
2013-11-23 07:07:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Twirl);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of actions group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif // __ACTION_CCGRID3D_ACTION_H__
|