Use struct `Vec2` instead `Size`

This commit is contained in:
halx99 2021-10-23 23:27:14 +08:00
parent 6bce6b49c4
commit 554412f4fd
151 changed files with 877 additions and 995 deletions

View File

@ -237,7 +237,7 @@ bool Follow::initWithTargetAndOffset(Node *followedNode, float xOffset,float yOf
_boundarySet = !rect.equals(Rect::ZERO);
_boundaryFullyCovered = false;
Size winSize = Director::getInstance()->getWinSize();
Vec2 winSize = Director::getInstance()->getWinSize();
_fullScreenSize.set(winSize.width, winSize.height);
_halfScreenSize = _fullScreenSize * 0.5f;
_offsetX=xOffset;

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#define __ACTIONS_CCACTION_H__
#include "base/CCRef.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "base/CCScriptSupport.h"
NS_CC_BEGIN

View File

@ -39,7 +39,7 @@
#include <vector>
#include "2d/CCActionInterval.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
NS_CC_BEGIN;

View File

@ -34,7 +34,7 @@ THE SOFTWARE.
NS_CC_BEGIN
// implementation of GridAction
bool GridAction::initWithDuration(float duration, const Size& gridSize)
bool GridAction::initWithDuration(float duration, const Vec2& gridSize)
{
if (ActionInterval::initWithDuration(duration))
{
@ -130,7 +130,7 @@ Rect Grid3DAction::getGridRect() const
}
// implementation of TiledGrid3DAction
TiledGrid3DAction* TiledGrid3DAction::create(float duration, const Size &gridSize)
TiledGrid3DAction* TiledGrid3DAction::create(float duration, const Vec2 &gridSize)
{
TiledGrid3DAction *ret = new (std::nothrow) TiledGrid3DAction();
if (ret && ret->initWithDuration(duration, gridSize))

View File

@ -73,10 +73,10 @@ CC_CONSTRUCTOR_ACCESS:
* @param gridSize The size of the GridAction should be.
* @return Return true when the initialization success, otherwise return false.
*/
bool initWithDuration(float duration, const Size& gridSize);
bool initWithDuration(float duration, const Vec2& gridSize);
protected:
Size _gridSize;
Vec2 _gridSize;
NodeGrid* _gridNodeTarget;
@ -150,7 +150,7 @@ public:
* @return A pointer of TiledGrid3DAction. If creation failed, return nil.
* @lua NA
*/
static TiledGrid3DAction* create(float duration, const Size& gridSize);
static TiledGrid3DAction* create(float duration, const Vec2& gridSize);
/**
* @brief Get the tile that belongs to a certain position of the grid.

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
NS_CC_BEGIN
// implementation of Waves3D
Waves3D* Waves3D::create(float duration, const Size& gridSize, unsigned int waves, float amplitude)
Waves3D* Waves3D::create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
{
Waves3D *action = new (std::nothrow) Waves3D();
@ -44,7 +44,7 @@ Waves3D* Waves3D::create(float duration, const Size& gridSize, unsigned int wave
return nullptr;
}
bool Waves3D::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude)
bool Waves3D::initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
{
if (Grid3DAction::initWithDuration(duration, gridSize))
{
@ -98,10 +98,10 @@ FlipX3D* FlipX3D::create(float duration)
bool FlipX3D::initWithDuration(float duration)
{
return Grid3DAction::initWithDuration(duration, Size(1, 1));
return Grid3DAction::initWithDuration(duration, Vec2(1, 1));
}
bool FlipX3D::initWithSize(const Size& gridSize, float duration)
bool FlipX3D::initWithSize(const Vec2& gridSize, float duration)
{
if (gridSize.width != 1 || gridSize.height != 1)
{
@ -284,7 +284,7 @@ void FlipY3D::update(float time)
// implementation of Lens3D
Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vec2& position, float radius)
Lens3D* Lens3D::create(float duration, const Vec2& gridSize, const Vec2& position, float radius)
{
Lens3D *action = new (std::nothrow) Lens3D();
@ -303,7 +303,7 @@ Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vec2& positio
return action;
}
bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius)
bool Lens3D::initWithDuration(float duration, const Vec2& gridSize, const Vec2& position, float radius)
{
if (Grid3DAction::initWithDuration(duration, gridSize))
{
@ -383,7 +383,7 @@ void Lens3D::update(float /*time*/)
// implementation of Ripple3D
Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
Ripple3D* Ripple3D::create(float duration, const Vec2& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
{
Ripple3D *action = new (std::nothrow) Ripple3D();
@ -402,7 +402,7 @@ Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vec2& pos
return action;
}
bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
bool Ripple3D::initWithDuration(float duration, const Vec2& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
{
if (Grid3DAction::initWithDuration(duration, gridSize))
{
@ -460,7 +460,7 @@ void Ripple3D::update(float time)
// implementation of Shaky3D
Shaky3D* Shaky3D::create(float duration, const Size& gridSize, int range, bool shakeZ)
Shaky3D* Shaky3D::create(float duration, const Vec2& gridSize, int range, bool shakeZ)
{
Shaky3D *action = new (std::nothrow) Shaky3D();
@ -479,7 +479,7 @@ Shaky3D* Shaky3D::create(float duration, const Size& gridSize, int range, bool s
return action;
}
bool Shaky3D::initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ)
bool Shaky3D::initWithDuration(float duration, const Vec2& gridSize, int range, bool shakeZ)
{
if (Grid3DAction::initWithDuration(duration, gridSize))
{
@ -525,7 +525,7 @@ void Shaky3D::update(float /*time*/)
// implementation of Liquid
Liquid* Liquid::create(float duration, const Size& gridSize, unsigned int waves, float amplitude)
Liquid* Liquid::create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
{
Liquid *action = new (std::nothrow) Liquid();
@ -544,7 +544,7 @@ Liquid* Liquid::create(float duration, const Size& gridSize, unsigned int waves,
return action;
}
bool Liquid::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude)
bool Liquid::initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
{
if (Grid3DAction::initWithDuration(duration, gridSize))
{
@ -586,7 +586,7 @@ void Liquid::update(float time)
// implementation of Waves
Waves* Waves::create(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical)
Waves* Waves::create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical)
{
Waves *action = new (std::nothrow) Waves();
@ -605,7 +605,7 @@ Waves* Waves::create(float duration, const Size& gridSize, unsigned int waves, f
return action;
}
bool Waves::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical)
bool Waves::initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical)
{
if (Grid3DAction::initWithDuration(duration, gridSize))
{
@ -658,7 +658,7 @@ void Waves::update(float time)
// implementation of Twirl
Twirl* Twirl::create(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude)
Twirl* Twirl::create(float duration, const Vec2& gridSize, const Vec2& position, unsigned int twirls, float amplitude)
{
Twirl *action = new (std::nothrow) Twirl();
@ -677,7 +677,7 @@ Twirl* Twirl::create(float duration, const Size& gridSize, const Vec2& position,
return action;
}
bool Twirl::initWithDuration(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude)
bool Twirl::initWithDuration(float duration, const Vec2& gridSize, const Vec2& position, unsigned int twirls, float amplitude)
{
if (Grid3DAction::initWithDuration(duration, gridSize))
{

View File

@ -53,7 +53,7 @@ public:
@param amplitude Specify the amplitude of the Waves3D action.
@return If the creation success, return a pointer of Waves3D action; otherwise, return nil.
*/
static Waves3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
static Waves3D* create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude);
/**
@brief Get the amplitude of the effect.
@ -93,7 +93,7 @@ CC_CONSTRUCTOR_ACCESS:
@param amplitude Specify the amplitude of the Waves3D action.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
bool initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude);
protected:
unsigned int _waves;
@ -139,7 +139,7 @@ CC_CONSTRUCTOR_ACCESS:
@param duration Specify the duration of the FlipX3D action. It's a value in seconds.
@return If the initialization success, return true; otherwise, return false.
*/
virtual bool initWithSize(const Size& gridSize, float duration);
virtual bool initWithSize(const Vec2& gridSize, float duration);
private:
CC_DISALLOW_COPY_AND_ASSIGN(FlipX3D);
@ -188,7 +188,7 @@ public:
@param radius Specify the radius of the lens.
@return If the creation success, return a pointer of Lens3D action; otherwise, return nil.
*/
static Lens3D* create(float duration, const Size& gridSize, const Vec2& position, float radius);
static Lens3D* create(float duration, const Vec2& gridSize, const Vec2& position, float radius);
/**
@brief Get the value of lens effect. Default value is 0.7.
@ -236,7 +236,7 @@ CC_CONSTRUCTOR_ACCESS:
@param radius Specify the radius of the lens effect.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius);
bool initWithDuration(float duration, const Vec2& gridSize, const Vec2& position, float radius);
protected:
/* lens center position */
@ -273,7 +273,7 @@ public:
@param amplitude Specify the amplitude of the ripple effect.
@return If the creation success, return a pointer of Ripple3D action; otherwise, return nil.
*/
static Ripple3D* create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
static Ripple3D* create(float duration, const Vec2& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
/**
@brief Get the center position of ripple effect.
@ -326,7 +326,7 @@ CC_CONSTRUCTOR_ACCESS:
@param amplitude Specify the amplitude of the ripple effect.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
bool initWithDuration(float duration, const Vec2& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
protected:
/* center position */
@ -357,7 +357,7 @@ public:
@param shakeZ Specify whether shake on the z axis.
@return If the creation success, return a pointer of Shaky3D action; otherwise, return nil.
*/
static Shaky3D* create(float initWithDuration, const Size& gridSize, int range, bool shakeZ);
static Shaky3D* create(float initWithDuration, const Vec2& gridSize, int range, bool shakeZ);
// Overrides
virtual Shaky3D* clone() const override;
@ -375,7 +375,7 @@ CC_CONSTRUCTOR_ACCESS:
@param shakeZ Specify whether shake on the z axis.
@return If the Initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ);
bool initWithDuration(float duration, const Vec2& gridSize, int range, bool shakeZ);
protected:
int _randrange;
@ -402,7 +402,7 @@ public:
@param amplitude Specify the amplitude of the Liquid action.
@return If the creation success, return a pointer of Liquid action; otherwise, return nil.
*/
static Liquid* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
static Liquid* create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude);
/**
@brief Get the amplitude of the effect.
@ -442,7 +442,7 @@ CC_CONSTRUCTOR_ACCESS:
@param amplitude Specify the amplitude of the Liquid action.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
bool initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude);
protected:
unsigned int _waves;
@ -473,7 +473,7 @@ public:
@param vertical Specify whether waves on vertical.
@return If the creation success, return a pointer of Waves action; otherwise, return nil.
*/
static Waves* create(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
static Waves* create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
/**
@brief Get the amplitude of the effect.
@ -515,7 +515,7 @@ CC_CONSTRUCTOR_ACCESS:
@param vertical Specify whether waves on vertical.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
bool initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical);
protected:
unsigned int _waves;
@ -546,7 +546,7 @@ public:
@param amplitude Specify the amplitude of the Twirl action.
@return If the creation success, return a pointer of Twirl action; otherwise, return nil.
*/
static Twirl* create(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude);
static Twirl* create(float duration, const Vec2& gridSize, const Vec2& position, unsigned int twirls, float amplitude);
/**
@brief Get the center position of twirl action.
@ -599,7 +599,7 @@ CC_CONSTRUCTOR_ACCESS:
@param amplitude Specify the amplitude of the Twirl action.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, unsigned int twirls, float amplitude);
bool initWithDuration(float duration, const Vec2& gridSize, const Vec2& position, unsigned int twirls, float amplitude);
protected:
/* twirl center */

View File

@ -1428,7 +1428,7 @@ SkewBy* SkewBy::reverse() const
return SkewBy::create(_duration, -_skewX, -_skewY);
}
ResizeTo* ResizeTo::create(float duration, const cocos2d::Size& final_size)
ResizeTo* ResizeTo::create(float duration, const Vec2& final_size)
{
ResizeTo *ret = new (std::nothrow) ResizeTo();
@ -1474,7 +1474,7 @@ void ResizeTo::update(float time)
}
}
bool ResizeTo::initWithDuration(float duration, const cocos2d::Size& final_size)
bool ResizeTo::initWithDuration(float duration, const Vec2& final_size)
{
if (cocos2d::ActionInterval::initWithDuration(duration))
{
@ -1489,7 +1489,7 @@ bool ResizeTo::initWithDuration(float duration, const cocos2d::Size& final_size)
// ResizeBy
//
ResizeBy* ResizeBy::create(float duration, const cocos2d::Size& deltaSize)
ResizeBy* ResizeBy::create(float duration, const Vec2& deltaSize)
{
ResizeBy *ret = new (std::nothrow) ResizeBy();
@ -1526,7 +1526,7 @@ void ResizeBy::startWithTarget(Node *target)
ResizeBy* ResizeBy::reverse() const
{
cocos2d::Size newSize(-_sizeDelta.width, -_sizeDelta.height);
Vec2 newSize(-_sizeDelta.width, -_sizeDelta.height);
return ResizeBy::create(_duration, newSize);
}
@ -1538,7 +1538,7 @@ void ResizeBy::update(float t)
}
}
bool ResizeBy::initWithDuration(float duration, const cocos2d::Size& deltaSize)
bool ResizeBy::initWithDuration(float duration, const Vec2& deltaSize)
{
bool ret = false;

View File

@ -736,19 +736,19 @@ private:
};
/** @class ResizeTo
* @brief Resize a Node object to the final size by modifying it's Size attribute.
* @brief Resize a Node object to the final size by modifying it's Vec2 attribute.
*/
class CC_DLL ResizeTo : public ActionInterval
{
public:
/**
* Creates the action.
* @brief Resize a Node object to the final size by modifying it's Size attribute. Works on all nodes where setContentSize is effective. But it's mostly useful for nodes where 9-slice is enabled
* @brief Resize a Node object to the final size by modifying it's Vec2 attribute. Works on all nodes where setContentSize is effective. But it's mostly useful for nodes where 9-slice is enabled
* @param duration Duration time, in seconds.
* @param final_size The target size to reach
* @return An autoreleased RotateTo object.
*/
static ResizeTo* create(float duration, const cocos2d::Size& final_size);
static ResizeTo* create(float duration, const Vec2& final_size);
//
// Overrides
@ -764,14 +764,14 @@ CC_CONSTRUCTOR_ACCESS:
/**
* initializes the action
* @param duration in seconds
* @param final_size in Size type
* @param final_size in Vec2 type
*/
bool initWithDuration(float duration, const cocos2d::Size& final_size);
bool initWithDuration(float duration, const Vec2& final_size);
protected:
cocos2d::Size _initialSize;
cocos2d::Size _finalSize;
cocos2d::Size _sizeDelta;
Vec2 _initialSize;
Vec2 _finalSize;
Vec2 _sizeDelta;
private:
CC_DISALLOW_COPY_AND_ASSIGN(ResizeTo);
@ -779,7 +779,7 @@ private:
/** @class ResizeBy
* @brief Resize a Node object by a Size. Works on all nodes where setContentSize is effective. But it's mostly useful for nodes where 9-slice is enabled
* @brief Resize a Node object by a Vec2. Works on all nodes where setContentSize is effective. But it's mostly useful for nodes where 9-slice is enabled
*/
class CC_DLL ResizeBy : public ActionInterval
{
@ -791,7 +791,7 @@ public:
* @param deltaSize The delta size.
* @return An autoreleased ResizeBy object.
*/
static ResizeBy* create(float duration, const cocos2d::Size& deltaSize);
static ResizeBy* create(float duration, const Vec2& deltaSize);
//
// Overrides
@ -809,12 +809,12 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~ResizeBy() {}
/** initializes the action */
bool initWithDuration(float duration, const cocos2d::Size& deltaSize);
bool initWithDuration(float duration, const Vec2& deltaSize);
protected:
cocos2d::Size _sizeDelta;
cocos2d::Size _startSize;
cocos2d::Size _previousSize;
Vec2 _sizeDelta;
Vec2 _startSize;
Vec2 _previousSize;
private:
CC_DISALLOW_COPY_AND_ASSIGN(ResizeBy);

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
NS_CC_BEGIN
PageTurn3D* PageTurn3D::create(float duration, const Size& gridSize)
PageTurn3D* PageTurn3D::create(float duration, const Vec2& gridSize)
{
PageTurn3D *action = new (std::nothrow) PageTurn3D();

View File

@ -59,7 +59,7 @@ public:
@param gridSize Specify the size of the grid.
@return If the creation success, return a pointer of PageTurn3D action; otherwise, return nil.
*/
static PageTurn3D* create(float duration, const Size& gridSize);
static PageTurn3D* create(float duration, const Vec2& gridSize);
// Overrides
virtual PageTurn3D* clone() const override;

View File

@ -36,12 +36,12 @@ struct Tile
{
Vec2 position;
Vec2 startPosition;
Size delta;
Vec2 delta;
};
// implementation of ShakyTiles3D
ShakyTiles3D* ShakyTiles3D::create(float duration, const Size& gridSize, int range, bool shakeZ)
ShakyTiles3D* ShakyTiles3D::create(float duration, const Vec2& gridSize, int range, bool shakeZ)
{
ShakyTiles3D *action = new (std::nothrow) ShakyTiles3D();
@ -55,7 +55,7 @@ ShakyTiles3D* ShakyTiles3D::create(float duration, const Size& gridSize, int ran
return nullptr;
}
bool ShakyTiles3D::initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ)
bool ShakyTiles3D::initWithDuration(float duration, const Vec2& gridSize, int range, bool shakeZ)
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
@ -112,7 +112,7 @@ void ShakyTiles3D::update(float /*time*/)
// implementation of ShatteredTiles3D
ShatteredTiles3D* ShatteredTiles3D::create(float duration, const Size& gridSize, int range, bool shatterZ)
ShatteredTiles3D* ShatteredTiles3D::create(float duration, const Vec2& gridSize, int range, bool shatterZ)
{
ShatteredTiles3D *action = new (std::nothrow) ShatteredTiles3D();
@ -126,7 +126,7 @@ ShatteredTiles3D* ShatteredTiles3D::create(float duration, const Size& gridSize,
return nullptr;
}
bool ShatteredTiles3D::initWithDuration(float duration, const Size& gridSize, int range, bool shatterZ)
bool ShatteredTiles3D::initWithDuration(float duration, const Vec2& gridSize, int range, bool shatterZ)
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
@ -189,7 +189,7 @@ void ShatteredTiles3D::update(float /*time*/)
// implementation of ShuffleTiles
ShuffleTiles* ShuffleTiles::create(float duration, const Size& gridSize, unsigned int seed)
ShuffleTiles* ShuffleTiles::create(float duration, const Vec2& gridSize, unsigned int seed)
{
ShuffleTiles *action = new (std::nothrow) ShuffleTiles();
@ -203,7 +203,7 @@ ShuffleTiles* ShuffleTiles::create(float duration, const Size& gridSize, unsigne
return nullptr;
}
bool ShuffleTiles::initWithDuration(float duration, const Size& gridSize, unsigned int seed)
bool ShuffleTiles::initWithDuration(float duration, const Vec2& gridSize, unsigned int seed)
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
@ -240,14 +240,14 @@ void ShuffleTiles::shuffle(unsigned int *array, unsigned int len)
}
}
Size ShuffleTiles::getDelta(const Size& pos) const
Vec2 ShuffleTiles::getDelta(const Vec2& pos) const
{
unsigned int idx = static_cast<unsigned int>(pos.width * _gridSize.height + pos.height);
Vec2 pos2;
pos2.x = (float)(_tilesOrder[idx] / (int)_gridSize.height);
pos2.y = (float)(_tilesOrder[idx] % (int)_gridSize.height);
return Size((int)(pos2.x - pos.width), (int)(pos2.y - pos.height));
return Vec2((int)(pos2.x - pos.width), (int)(pos2.y - pos.height));
}
void ShuffleTiles::placeTile(const Vec2& pos, Tile *t)
@ -302,7 +302,7 @@ void ShuffleTiles::startWithTarget(Node *target)
{
tileArray->position.set((float)i, (float)j);
tileArray->startPosition.set((float)i, (float)j);
tileArray->delta = getDelta(Size((float)i, (float)j));
tileArray->delta = getDelta(Vec2((float)i, (float)j));
++tileArray;
}
}
@ -325,7 +325,7 @@ void ShuffleTiles::update(float time)
// implementation of FadeOutTRTiles
FadeOutTRTiles* FadeOutTRTiles::create(float duration, const Size& gridSize)
FadeOutTRTiles* FadeOutTRTiles::create(float duration, const Vec2& gridSize)
{
FadeOutTRTiles *action = new (std::nothrow) FadeOutTRTiles();
@ -345,7 +345,7 @@ FadeOutTRTiles* FadeOutTRTiles::clone() const
return FadeOutTRTiles::create(_duration, _gridSize);
}
float FadeOutTRTiles::testFunc(const Size& pos, float time)
float FadeOutTRTiles::testFunc(const Vec2& pos, float time)
{
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
if ((n.x + n.y) == 0.0f)
@ -395,7 +395,7 @@ void FadeOutTRTiles::update(float time)
for (int j = 0; j < _gridSize.height; ++j)
{
Vec2 pos((float)i, (float)j);
float distance = testFunc(Size((float)i, (float)j), time);
float distance = testFunc(Vec2((float)i, (float)j), time);
if ( distance == 0 )
{
turnOffTile(pos);
@ -414,7 +414,7 @@ void FadeOutTRTiles::update(float time)
// implementation of FadeOutBLTiles
FadeOutBLTiles* FadeOutBLTiles::create(float duration, const Size& gridSize)
FadeOutBLTiles* FadeOutBLTiles::create(float duration, const Vec2& gridSize)
{
FadeOutBLTiles *action = new (std::nothrow) FadeOutBLTiles();
@ -434,7 +434,7 @@ FadeOutBLTiles* FadeOutBLTiles::clone() const
return FadeOutBLTiles::create(_duration, _gridSize);
}
float FadeOutBLTiles::testFunc(const Size& pos, float time)
float FadeOutBLTiles::testFunc(const Vec2& pos, float time)
{
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
if ((pos.width + pos.height) == 0)
@ -447,7 +447,7 @@ float FadeOutBLTiles::testFunc(const Size& pos, float time)
// implementation of FadeOutUpTiles
FadeOutUpTiles* FadeOutUpTiles::create(float duration, const Size& gridSize)
FadeOutUpTiles* FadeOutUpTiles::create(float duration, const Vec2& gridSize)
{
FadeOutUpTiles *action = new (std::nothrow) FadeOutUpTiles();
@ -467,7 +467,7 @@ FadeOutUpTiles* FadeOutUpTiles::clone() const
return FadeOutUpTiles::create(_duration, _gridSize);
}
float FadeOutUpTiles::testFunc(const Size& pos, float time)
float FadeOutUpTiles::testFunc(const Vec2& pos, float time)
{
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
if (n.y == 0.0f)
@ -493,7 +493,7 @@ void FadeOutUpTiles::transformTile(const Vec2& pos, float distance)
// implementation of FadeOutDownTiles
FadeOutDownTiles* FadeOutDownTiles::create(float duration, const Size& gridSize)
FadeOutDownTiles* FadeOutDownTiles::create(float duration, const Vec2& gridSize)
{
FadeOutDownTiles *action = new (std::nothrow) FadeOutDownTiles();
@ -513,7 +513,7 @@ FadeOutDownTiles* FadeOutDownTiles::clone() const
return FadeOutDownTiles::create(_duration, _gridSize);
}
float FadeOutDownTiles::testFunc(const Size& pos, float time)
float FadeOutDownTiles::testFunc(const Vec2& pos, float time)
{
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
return powf(n.y / (pos.height > 0.0f ? pos.height : 0.1f), 6);
@ -521,7 +521,7 @@ float FadeOutDownTiles::testFunc(const Size& pos, float time)
// implementation of TurnOffTiles
TurnOffTiles* TurnOffTiles::create(float duration, const Size& gridSize)
TurnOffTiles* TurnOffTiles::create(float duration, const Vec2& gridSize)
{
TurnOffTiles* action = new (std::nothrow) TurnOffTiles();
if (action && action->initWithDuration(duration, gridSize, 0))
@ -534,7 +534,7 @@ TurnOffTiles* TurnOffTiles::create(float duration, const Size& gridSize)
return nullptr;
}
TurnOffTiles* TurnOffTiles::create(float duration, const Size& gridSize, unsigned int seed)
TurnOffTiles* TurnOffTiles::create(float duration, const Vec2& gridSize, unsigned int seed)
{
TurnOffTiles *action = new (std::nothrow) TurnOffTiles();
@ -548,7 +548,7 @@ TurnOffTiles* TurnOffTiles::create(float duration, const Size& gridSize, unsigne
return nullptr;
}
bool TurnOffTiles::initWithDuration(float duration, const Size& gridSize, unsigned int seed)
bool TurnOffTiles::initWithDuration(float duration, const Vec2& gridSize, unsigned int seed)
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
@ -641,7 +641,7 @@ void TurnOffTiles::update(float time)
// implementation of WavesTiles3D
WavesTiles3D* WavesTiles3D::create(float duration, const Size& gridSize, unsigned int waves, float amplitude)
WavesTiles3D* WavesTiles3D::create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
{
WavesTiles3D *action = new (std::nothrow) WavesTiles3D();
@ -655,7 +655,7 @@ WavesTiles3D* WavesTiles3D::create(float duration, const Size& gridSize, unsigne
return nullptr;
}
bool WavesTiles3D::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude)
bool WavesTiles3D::initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
@ -697,7 +697,7 @@ void WavesTiles3D::update(float time)
// implementation of JumpTiles3D
JumpTiles3D* JumpTiles3D::create(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude)
JumpTiles3D* JumpTiles3D::create(float duration, const Vec2& gridSize, unsigned int numberOfJumps, float amplitude)
{
JumpTiles3D *action = new (std::nothrow) JumpTiles3D();
@ -711,7 +711,7 @@ JumpTiles3D* JumpTiles3D::create(float duration, const Size& gridSize, unsigned
return nullptr;
}
bool JumpTiles3D::initWithDuration(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude)
bool JumpTiles3D::initWithDuration(float duration, const Vec2& gridSize, unsigned int numberOfJumps, float amplitude)
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
@ -783,7 +783,7 @@ bool SplitRows::initWithDuration(float duration, unsigned int rows)
{
_rows = rows;
return TiledGrid3DAction::initWithDuration(duration, Size(1.0f, (float)rows));
return TiledGrid3DAction::initWithDuration(duration, Vec2(1.0f, (float)rows));
}
SplitRows* SplitRows::clone() const
@ -839,7 +839,7 @@ SplitCols* SplitCols::create(float duration, unsigned int cols)
bool SplitCols::initWithDuration(float duration, unsigned int cols)
{
_cols = cols;
return TiledGrid3DAction::initWithDuration(duration, Size((float)cols, 1.0f));
return TiledGrid3DAction::initWithDuration(duration, Vec2((float)cols, 1.0f));
}
SplitCols* SplitCols::clone() const

View File

@ -53,7 +53,7 @@ public:
@param shakeZ Specify whether shake on the z axis.
@return If the creation success, return a pointer of ShakyTiles3D action; otherwise, return nil.
*/
static ShakyTiles3D* create(float duration, const Size& gridSize, int range, bool shakeZ);
static ShakyTiles3D* create(float duration, const Vec2& gridSize, int range, bool shakeZ);
// Override
virtual ShakyTiles3D* clone() const override;
@ -71,7 +71,7 @@ CC_CONSTRUCTOR_ACCESS:
@param shakeZ Specify whether shake on the z axis.
@return If the Initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ);
bool initWithDuration(float duration, const Vec2& gridSize, int range, bool shakeZ);
protected:
int _randrange;
@ -98,7 +98,7 @@ public:
* @param shatterZ Specify whether shatter on the z axis.
* @return If the creation success, return a pointer of ShatteredTiles3D action; otherwise, return nil.
*/
static ShatteredTiles3D* create(float duration, const Size& gridSize, int range, bool shatterZ);
static ShatteredTiles3D* create(float duration, const Vec2& gridSize, int range, bool shatterZ);
// Override
virtual ShatteredTiles3D* clone() const override;
@ -116,7 +116,7 @@ CC_CONSTRUCTOR_ACCESS:
@param shatterZ Specify whether shake on the z axis.
@return If the Initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, int range, bool shatterZ);
bool initWithDuration(float duration, const Vec2& gridSize, int range, bool shatterZ);
protected:
int _randrange;
@ -144,10 +144,10 @@ public:
* @param seed Specify the random seed.
* @return If the creation success, return a pointer of ShuffleTiles action; otherwise, return nil.
*/
static ShuffleTiles* create(float duration, const Size& gridSize, unsigned int seed);
static ShuffleTiles* create(float duration, const Vec2& gridSize, unsigned int seed);
void shuffle(unsigned int *array, unsigned int len);
Size getDelta(const Size& pos) const;
Vec2 getDelta(const Vec2& pos) const;
void placeTile(const Vec2& pos, Tile *t);
// Overrides
@ -166,7 +166,7 @@ CC_CONSTRUCTOR_ACCESS:
* @param seed Specify the random seed.
* @return If the Initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
bool initWithDuration(float duration, const Vec2& gridSize, unsigned int seed);
protected:
unsigned int _seed;
@ -191,7 +191,7 @@ public:
* @param gridSize Specify the size of the grid.
* @return If the creation success, return a pointer of FadeOutTRTiles action; otherwise, return nil.
*/
static FadeOutTRTiles* create(float duration, const Size& gridSize);
static FadeOutTRTiles* create(float duration, const Vec2& gridSize);
/**
@brief Calculate the percentage a tile should be shown.
@ -199,7 +199,7 @@ public:
@param time The current percentage of the action.
@return Return the percentage the tile should be shown.
*/
virtual float testFunc(const Size& pos, float time);
virtual float testFunc(const Vec2& pos, float time);
/**
@brief Show the tile at specified position.
@ -245,10 +245,10 @@ public:
* @param gridSize Specify the size of the grid.
* @return If the creation success, return a pointer of FadeOutBLTiles action; otherwise, return nil.
*/
static FadeOutBLTiles* create(float duration, const Size& gridSize);
static FadeOutBLTiles* create(float duration, const Vec2& gridSize);
// Overrides
virtual float testFunc(const Size& pos, float time) override;
virtual float testFunc(const Vec2& pos, float time) override;
virtual FadeOutBLTiles* clone() const override;
CC_CONSTRUCTOR_ACCESS:
@ -272,13 +272,13 @@ public:
* @param gridSize Specify the size of the grid.
* @return If the creation success, return a pointer of FadeOutUpTiles action; otherwise, return nil.
*/
static FadeOutUpTiles* create(float duration, const Size& gridSize);
static FadeOutUpTiles* create(float duration, const Vec2& gridSize);
virtual void transformTile(const Vec2& pos, float distance) override;
// Overrides
virtual FadeOutUpTiles* clone() const override;
virtual float testFunc(const Size& pos, float time) override;
virtual float testFunc(const Vec2& pos, float time) override;
CC_CONSTRUCTOR_ACCESS:
FadeOutUpTiles() {}
@ -301,11 +301,11 @@ public:
* @param gridSize Specify the size of the grid.
* @return If the creation success, return a pointer of FadeOutDownTiles action; otherwise, return nil.
*/
static FadeOutDownTiles* create(float duration, const Size& gridSize);
static FadeOutDownTiles* create(float duration, const Vec2& gridSize);
// Overrides
virtual FadeOutDownTiles* clone() const override;
virtual float testFunc(const Size& pos, float time) override;
virtual float testFunc(const Vec2& pos, float time) override;
CC_CONSTRUCTOR_ACCESS:
FadeOutDownTiles() {}
@ -328,7 +328,7 @@ public:
* @param gridSize Specify the size of the grid.
* @return If the creation success, return a pointer of TurnOffTiles action; otherwise, return nil.
*/
static TurnOffTiles* create(float duration, const Size& gridSize);
static TurnOffTiles* create(float duration, const Vec2& gridSize);
/**
* @brief Create the action with the grid size and the duration.
* @param duration Specify the duration of the TurnOffTiles action. It's a value in seconds.
@ -336,7 +336,7 @@ public:
* @param seed Specify the random seed.
* @return If the creation success, return a pointer of TurnOffTiles action; otherwise, return nil.
*/
static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed);
static TurnOffTiles* create(float duration, const Vec2& gridSize, unsigned int seed);
/**
@brief Shuffle the array specified.
@ -373,7 +373,7 @@ CC_CONSTRUCTOR_ACCESS:
* @param seed Specify the random seed.
* @return If the Initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
bool initWithDuration(float duration, const Vec2& gridSize, unsigned int seed);
protected:
unsigned int _seed;
@ -399,7 +399,7 @@ public:
* @param amplitude Specify the amplitude of the WavesTiles3D action.
* @return If the creation success, return a pointer of WavesTiles3D action; otherwise, return nil.
*/
static WavesTiles3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude);
static WavesTiles3D* create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude);
/**
@brief Get the amplitude of the effect.
@ -439,7 +439,7 @@ CC_CONSTRUCTOR_ACCESS:
@param amplitude Specify the amplitude of the WavesTiles3D action.
@return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
bool initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude);
protected:
unsigned int _waves;
@ -465,7 +465,7 @@ public:
* @param amplitude Specify the amplitude of the JumpTiles3D action.
* @return If the creation success, return a pointer of JumpTiles3D action; otherwise, return nil.
*/
static JumpTiles3D* create(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude);
static JumpTiles3D* create(float duration, const Vec2& gridSize, unsigned int numberOfJumps, float amplitude);
/**
@brief Get the amplitude of the effect.
@ -505,7 +505,7 @@ CC_CONSTRUCTOR_ACCESS:
* @param amplitude Specify the amplitude of the JumpTiles3D action.
* @return If the initialization success, return true; otherwise, return false.
*/
bool initWithDuration(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude);
bool initWithDuration(float duration, const Vec2& gridSize, unsigned int numberOfJumps, float amplitude);
protected:
unsigned int _jumps;
@ -551,7 +551,7 @@ CC_CONSTRUCTOR_ACCESS:
protected:
unsigned int _rows;
Size _winSize;
Vec2 _winSize;
private:
CC_DISALLOW_COPY_AND_ASSIGN(SplitRows);
@ -596,7 +596,7 @@ CC_CONSTRUCTOR_ACCESS:
protected:
unsigned int _cols;
Size _winSize;
Vec2 _winSize;
private:
CC_DISALLOW_COPY_AND_ASSIGN(SplitCols);

View File

@ -138,7 +138,7 @@ bool AtlasNode::setProgramState(backend::ProgramState* programState, bool needsR
void AtlasNode::calculateMaxItems()
{
Size s = _textureAtlas->getTexture()->getContentSize();
Vec2 s = _textureAtlas->getTexture()->getContentSize();
if (_ignoreContentScaleFactor)
{
@ -229,7 +229,7 @@ void AtlasNode::setIgnoreContentScaleFactor(bool ignoreContentScaleFactor)
auto label = dynamic_cast<LabelProtocol*>(this);
if (label) {
Size s = Size(label->getString().size() * _itemWidth, _itemHeight);
Vec2 s = Vec2(label->getString().size() * _itemWidth, _itemHeight);
this->setContentSize(s);
}
}

View File

@ -247,7 +247,7 @@ unsigned int AutoPolygon::getSquareValue(unsigned int x, unsigned int y, const R
*/
unsigned int sv = 0;
//NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel
auto fixedRect = Rect(rect.origin, rect.size-Size(2,2));
auto fixedRect = Rect(rect.origin, rect.size-Vec2(2,2));
Vec2 tl = Vec2(x-1.0f, y-1.0f);
sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold)? 1 : 0;

View File

@ -291,7 +291,7 @@ Vec3 Camera::unprojectGL(const Vec3& src) const
return dst;
}
void Camera::unproject(const Size& viewport, const Vec3* src, Vec3* dst) const
void Camera::unproject(const Vec2& viewport, const Vec3* src, Vec3* dst) const
{
CCASSERT(src && dst, "vec3 can not be null");
@ -311,7 +311,7 @@ void Camera::unproject(const Size& viewport, const Vec3* src, Vec3* dst) const
dst->set(screen.x, screen.y, screen.z);
}
void Camera::unprojectGL(const Size& viewport, const Vec3* src, Vec3* dst) const
void Camera::unprojectGL(const Vec2& viewport, const Vec3* src, Vec3* dst) const
{
CCASSERT(src && dst, "vec3 can not be null");

View File

@ -188,7 +188,7 @@ public:
* @param src The screen-space position.
* @param dst The 3D world-space position.
*/
void unproject(const Size& size, const Vec3* src, Vec3* dst) const;
void unproject(const Vec2& size, const Vec3* src, Vec3* dst) const;
/**
* Convert the specified point of GL-screen-space coordinate into the 3D world-space coordinate.
@ -198,7 +198,7 @@ public:
* @param src The GL-screen-space position.
* @param dst The 3D world-space position.
*/
void unprojectGL(const Size& size, const Vec3* src, Vec3* dst) const;
void unprojectGL(const Vec2& size, const Vec3* src, Vec3* dst) const;
/**
* Is this aabb visible in frustum

View File

@ -100,7 +100,7 @@ bool FastTMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo
Vec2 offset = this->calculateLayerOffset(layerInfo->_offset);
this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));
this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));
this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Vec2(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));
this->tileToNodeTransform();
@ -135,7 +135,7 @@ void FastTMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flag
if( flags != 0 || _dirty || _quadsDirty)
{
Size s = _director->getVisibleSize();
Vec2 s = _director->getVisibleSize();
const Vec2 &anchor = getAnchorPoint();
auto rect = Rect(Camera::getVisitingCamera()->getPositionX() - s.width * (anchor.x == 0.0f ? 0.5f : anchor.x),
Camera::getVisitingCamera()->getPositionY() - s.height * (anchor.y == 0.0f ? 0.5f : anchor.y),
@ -169,8 +169,8 @@ void FastTMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flag
void FastTMXLayer::updateTiles(const Rect& culledRect)
{
Rect visibleTiles = Rect(culledRect.origin, culledRect.size * _director->getContentScaleFactor());
Size mapTileSize = CC_SIZE_PIXELS_TO_POINTS(_mapTileSize);
Size tileSize = CC_SIZE_PIXELS_TO_POINTS(_tileSet->_tileSize);
Vec2 mapTileSize = CC_SIZE_PIXELS_TO_POINTS(_mapTileSize);
Vec2 tileSize = CC_SIZE_PIXELS_TO_POINTS(_tileSet->_tileSize);
Mat4 nodeToTileTransform = _tileToNodeTransform.getInversed();
//transform to tile
visibleTiles = RectApplyTransform(visibleTiles, nodeToTileTransform);
@ -510,8 +510,8 @@ void FastTMXLayer::updateTotalQuads()
{
if(_quadsDirty)
{
Size tileSize = CC_SIZE_PIXELS_TO_POINTS(_tileSet->_tileSize);
Size texSize = _tileSet->_imageSize;
Vec2 tileSize = CC_SIZE_PIXELS_TO_POINTS(_tileSet->_tileSize);
Vec2 texSize = _tileSet->_imageSize;
_tileToQuadIndex.clear();
_totalQuads.resize(int(_layerSize.width * _layerSize.height));
_indices.resize(6 * int(_layerSize.width * _layerSize.height));

View File

@ -165,29 +165,29 @@ public:
*/
void setLayerName(const std::string& layerName) { _layerName = layerName; }
/** Size of the layer in tiles.
/** Vec2 of the layer in tiles.
*
* @return Size of the layer in tiles.
* @return Vec2 of the layer in tiles.
*/
const Size& getLayerSize() const { return _layerSize; }
const Vec2& getLayerSize() const { return _layerSize; }
/** Set the size of the layer in tiles.
*
* @param size The new size of the layer in tiles.
*/
void setLayerSize(const Size& size) { _layerSize = size; }
void setLayerSize(const Vec2& size) { _layerSize = size; }
/** Size of the map's tile (could be different from the tile's size).
/** Vec2 of the map's tile (could be different from the tile's size).
*
* @return Size of the map's tile (could be different from the tile's size).
* @return Vec2 of the map's tile (could be different from the tile's size).
*/
const Size& getMapTileSize() const { return _mapTileSize; }
const Vec2& getMapTileSize() const { return _mapTileSize; }
/** Set the size of the map's tile.
*
* @param size The new size of the map's tile.
*/
void setMapTileSize(const Size& size) { _mapTileSize = size; }
void setMapTileSize(const Vec2& size) { _mapTileSize = size; }
/** Pointer to the map of tiles.
* @js NA
@ -326,9 +326,9 @@ protected:
std::string _layerName;
/** size of the layer in tiles */
Size _layerSize;
Vec2 _layerSize;
/** size of the map's tile (could be different from the tile's size) */
Size _mapTileSize;
Vec2 _mapTileSize;
/** pointer to the map of tiles */
uint32_t* _tiles = nullptr;
/** Tileset information for the layer */
@ -350,7 +350,7 @@ protected:
/** container for sprite children. map<index, pair<sprite, gid> > */
std::map<int, std::pair<Sprite*, int> > _spriteContainer;
Size _screenGridSize;
Vec2 _screenGridSize;
Rect _screenGridRect;
int _screenTileCount = 0;

View File

@ -61,7 +61,7 @@ bool FastTMXTiledMap::initWithTMXFile(const std::string& tmxFile)
{
CCASSERT(tmxFile.size()>0, "FastTMXTiledMap: tmx file should not be empty");
setContentSize(Size::ZERO);
setContentSize(Vec2::ZERO);
TMXMapInfo *mapInfo = TMXMapInfo::create(tmxFile);
@ -79,7 +79,7 @@ bool FastTMXTiledMap::initWithTMXFile(const std::string& tmxFile)
bool FastTMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath)
{
setContentSize(Size::ZERO);
setContentSize(Vec2::ZERO);
TMXMapInfo *mapInfo = TMXMapInfo::createWithXML(tmxString, resourcePath);
@ -90,8 +90,8 @@ bool FastTMXTiledMap::initWithXML(const std::string& tmxString, const std::strin
}
FastTMXTiledMap::FastTMXTiledMap()
:_mapSize(Size::ZERO)
,_tileSize(Size::ZERO)
:_mapSize(Vec2::ZERO)
,_tileSize(Vec2::ZERO)
{
}
@ -117,7 +117,7 @@ FastTMXLayer * FastTMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *
TMXTilesetInfo * FastTMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
Size size = layerInfo->_layerSize;
Vec2 size = layerInfo->_layerSize;
auto& tilesets = mapInfo->getTilesets();
for (auto iter = tilesets.crbegin(), iterCrend = tilesets.crend(); iter != iterCrend; ++iter)
@ -185,8 +185,8 @@ void FastTMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
addChild(child, idx, idx);
// update content size with the max size
const Size& childSize = child->getContentSize();
Size currentSize = this->getContentSize();
const Vec2& childSize = child->getContentSize();
Vec2 currentSize = this->getContentSize();
currentSize.width = std::max( currentSize.width, childSize.width );
currentSize.height = std::max( currentSize.height, childSize.height );
this->setContentSize(currentSize);

View File

@ -138,25 +138,25 @@ public:
*
* @return The map's size property measured in tiles.
*/
const Size& getMapSize() const { return _mapSize; }
const Vec2& getMapSize() const { return _mapSize; }
/** Set the map's size property measured in tiles.
*
* @param mapSize The map's size property measured in tiles.
*/
void setMapSize(const Size& mapSize) { _mapSize = mapSize; }
void setMapSize(const Vec2& mapSize) { _mapSize = mapSize; }
/** The tiles's size property measured in pixels.
*
* @return The tiles's size property measured in pixels.
*/
const Size& getTileSize() const { return _tileSize; }
const Vec2& getTileSize() const { return _tileSize; }
/** Set the tiles's size property measured in pixels.
*
* @param tileSize The tiles's size property measured in pixels.
*/
void setTileSize(const Size& tileSize) { _tileSize = tileSize; }
void setTileSize(const Vec2& tileSize) { _tileSize = tileSize; }
/** Get map orientation.
*
@ -235,9 +235,9 @@ protected:
void buildWithMapInfo(TMXMapInfo* mapInfo);
/** the map's size property measured in tiles */
Size _mapSize;
Vec2 _mapSize;
/** the tiles's size property measured in pixels */
Size _tileSize;
Vec2 _tileSize;
/** map orientation */
int _mapOrientation;
/** object groups */

View File

@ -154,7 +154,7 @@ void FontAtlas::initTextureWithZeros(Texture2D *texture)
}
zeros = new char[zeroBytes]();
//std::fill(zeros, zeros + cnt, 0);
texture->initWithData(zeros, zeroBytes, pixelFormat, CacheTextureWidth, CacheTextureHeight, Size(CacheTextureWidth, CacheTextureHeight));
texture->initWithData(zeros, zeroBytes, pixelFormat, CacheTextureWidth, CacheTextureHeight, Vec2(CacheTextureWidth, CacheTextureHeight));
delete[] zeros;
}

View File

@ -110,7 +110,7 @@ FontAtlas * FontCharMap::createFontAtlas()
if (!tempAtlas)
return nullptr;
Size s = _texture->getContentSizeInPixels();
Vec2 s = _texture->getContentSizeInPixels();
int itemsPerColumn = (int)(s.height / _itemHeight);
int itemsPerRow = (int)(s.width / _itemWidth);

View File

@ -92,7 +92,7 @@ public://@public
// Character Set defines the letters that actually exist in the font
std::set<unsigned int>* _characterSet;
//! Font Size
//! Font Vec2
int _fontSize;
public:
/**

View File

@ -42,15 +42,15 @@ THE SOFTWARE.
NS_CC_BEGIN
// implementation of GridBase
bool GridBase::initWithSize(const Size& gridSize)
bool GridBase::initWithSize(const Vec2& gridSize)
{
return initWithSize(gridSize, Rect::ZERO);
}
bool GridBase::initWithSize(const cocos2d::Size &gridSize, const cocos2d::Rect &rect)
bool GridBase::initWithSize(const Vec2 &gridSize, const cocos2d::Rect &rect)
{
Director *director = Director::getInstance();
Size s = director->getWinSizeInPixels();
Vec2 s = director->getWinSizeInPixels();
auto POTWide = ccNextPOT((unsigned int)s.width);
auto POTHigh = ccNextPOT((unsigned int)s.height);
@ -76,12 +76,12 @@ bool GridBase::initWithSize(const cocos2d::Size &gridSize, const cocos2d::Rect &
return true;
}
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipped)
bool GridBase::initWithSize(const Vec2& gridSize, Texture2D *texture, bool flipped)
{
return initWithSize(gridSize, texture, flipped, Rect::ZERO);
}
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
bool GridBase::initWithSize(const Vec2& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
{
bool ret = true;
@ -186,7 +186,7 @@ void GridBase::setTextureFlipped(bool flipped)
void GridBase::set2DProjection()
{
Director *director = Director::getInstance();
Size size = director->getWinSizeInPixels();
Vec2 size = director->getWinSizeInPixels();
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
@ -215,7 +215,7 @@ void GridBase::beforeDraw()
_beforeDrawCommand.func = [=]() -> void {
_directorProjection = director->getProjection();
set2DProjection();
Size size = director->getWinSizeInPixels();
Vec2 size = director->getWinSizeInPixels();
renderer->setViewPort(0, 0, (unsigned int)size.width, (unsigned int)size.height);
_oldRenderTarget = renderer->getRenderTarget();
@ -275,7 +275,7 @@ void GridBase::afterDraw(cocos2d::Node * /*target*/)
// implementation of Grid3D
Grid3D* Grid3D::create(const Size& gridSize)
Grid3D* Grid3D::create(const Vec2& gridSize)
{
Grid3D *ret= new (std::nothrow) Grid3D();
@ -295,7 +295,7 @@ Grid3D* Grid3D::create(const Size& gridSize)
return ret;
}
Grid3D* Grid3D::create(const Size& gridSize, const Rect& rect)
Grid3D* Grid3D::create(const Vec2& gridSize, const Rect& rect)
{
Grid3D *ret= new (std::nothrow) Grid3D();
@ -315,7 +315,7 @@ Grid3D* Grid3D::create(const Size& gridSize, const Rect& rect)
return ret;
}
Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool flipped)
Grid3D* Grid3D::create(const Vec2& gridSize, Texture2D *texture, bool flipped)
{
Grid3D *ret= new (std::nothrow) Grid3D();
@ -335,7 +335,7 @@ Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool flipped)
return ret;
}
Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
Grid3D* Grid3D::create(const Vec2& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
{
Grid3D *ret= new (std::nothrow) Grid3D();
@ -570,7 +570,7 @@ TiledGrid3D::~TiledGrid3D()
CC_SAFE_FREE(_indices);
}
TiledGrid3D* TiledGrid3D::create(const Size& gridSize)
TiledGrid3D* TiledGrid3D::create(const Vec2& gridSize)
{
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
@ -590,7 +590,7 @@ TiledGrid3D* TiledGrid3D::create(const Size& gridSize)
return ret;
}
TiledGrid3D* TiledGrid3D::create(const Size& gridSize, const Rect& rect)
TiledGrid3D* TiledGrid3D::create(const Vec2& gridSize, const Rect& rect)
{
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
@ -610,7 +610,7 @@ TiledGrid3D* TiledGrid3D::create(const Size& gridSize, const Rect& rect)
return ret;
}
TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
TiledGrid3D* TiledGrid3D::create(const Vec2& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
{
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
@ -630,7 +630,7 @@ TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool
return ret;
}
TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool flipped)
TiledGrid3D* TiledGrid3D::create(const Vec2& gridSize, Texture2D *texture, bool flipped)
{
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();

View File

@ -84,10 +84,10 @@ public:
@param flipped whether or not the grab texture should be flip by Y or not.
@param rect The effective grid rect.
*/
bool initWithSize(const Size& gridSize);
bool initWithSize(const Size& gridSize, const Rect& rect);
bool initWithSize(const Size& gridSize, Texture2D *texture, bool flipped);
bool initWithSize(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
bool initWithSize(const Vec2& gridSize);
bool initWithSize(const Vec2& gridSize, const Rect& rect);
bool initWithSize(const Vec2& gridSize, Texture2D *texture, bool flipped);
bool initWithSize(const Vec2& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
/**@}*/
/** @{
@ -102,10 +102,10 @@ public:
/** Set number of times that the grid will be reused. */
void setReuseGrid(int reuseGrid) { _reuseGrid = reuseGrid; }
/** Size of the grid. */
const Size& getGridSize() const { return _gridSize; }
/** Vec2 of the grid. */
const Vec2& getGridSize() const { return _gridSize; }
/**Set the size of the grid.*/
void setGridSize(const Size& gridSize) { _gridSize = gridSize; }
void setGridSize(const Vec2& gridSize) { _gridSize = gridSize; }
/** Pixels between the grids. */
const Vec2& getStep() const { return _step; }
@ -143,7 +143,7 @@ protected:
bool _active = false;
int _reuseGrid = 0;
Size _gridSize;
Vec2 _gridSize;
Texture2D *_texture = nullptr;
Vec2 _step;
bool _isTextureFlipped = false;
@ -177,13 +177,13 @@ class CC_DLL Grid3D : public GridBase
{
public:
/** create one Grid. */
static Grid3D* create(const Size& gridSize);
static Grid3D* create(const Vec2& gridSize);
/** create one Grid. */
static Grid3D* create(const Size& gridSize, const Rect& rect);
static Grid3D* create(const Vec2& gridSize, const Rect& rect);
/** create one Grid. */
static Grid3D* create(const Size& gridSize, Texture2D *texture, bool flipped);
static Grid3D* create(const Vec2& gridSize, Texture2D *texture, bool flipped);
/** create one Grid. */
static Grid3D* create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
static Grid3D* create(const Vec2& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
/**
Constructor.
* @js ctor
@ -251,13 +251,13 @@ class CC_DLL TiledGrid3D : public GridBase
{
public:
/** Create one Grid. */
static TiledGrid3D* create(const Size& gridSize);
static TiledGrid3D* create(const Vec2& gridSize);
/** Create one Grid. */
static TiledGrid3D* create(const Size& gridSize, const Rect& rect);
static TiledGrid3D* create(const Vec2& gridSize, const Rect& rect);
/** Create one Grid. */
static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool flipped);
static TiledGrid3D* create(const Vec2& gridSize, Texture2D *texture, bool flipped);
/** Create one Grid. */
static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
static TiledGrid3D* create(const Vec2& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
/**@{
Implementations for interfaces in base class.

View File

@ -106,7 +106,7 @@ public:
if (isDirty())
{
_transformToBatch = getNodeToParentTransform();
Size &size = _rect.size;
Vec2 &size = _rect.size;
float x1 = _offsetPosition.x;
float y1 = _offsetPosition.y;
@ -250,7 +250,7 @@ Label* Label::create()
return ret;
}
Label* Label::createWithSystemFont(const std::string& text, const std::string& font, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
Label* Label::createWithSystemFont(const std::string& text, const std::string& font, float fontSize, const Vec2& dimensions /* = Vec2::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
auto ret = new (std::nothrow) Label(hAlignment,vAlignment);
@ -269,7 +269,7 @@ Label* Label::createWithSystemFont(const std::string& text, const std::string& f
return nullptr;
}
Label* Label::createWithTTF(const std::string& text, const std::string& fontFile, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
Label* Label::createWithTTF(const std::string& text, const std::string& fontFile, float fontSize, const Vec2& dimensions /* = Vec2::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
auto ret = new (std::nothrow) Label(hAlignment,vAlignment);
@ -414,7 +414,7 @@ bool Label::setCharMap(const std::string& plistFile)
bool Label::initWithTTF(const std::string& text,
const std::string& fontFilePath, float fontSize,
const Size& dimensions,
const Vec2& dimensions,
TextHAlignment /*hAlignment*/, TextVAlignment /*vAlignment*/)
{
if (FileUtils::getInstance()->isFileExist(fontFilePath))
@ -1067,7 +1067,7 @@ bool Label::alignText()
{
if (_fontAtlas == nullptr || _utf32Text.empty())
{
setContentSize(Size::ZERO);
setContentSize(Vec2::ZERO);
return true;
}
@ -1374,7 +1374,7 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */
}
void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,
const Size &offset /* = Size(2 ,-2)*/,
const Vec2 &offset /* = Vec2(2 ,-2)*/,
int /* blurRadius = 0 */)
{
_shadowEnabled = true;
@ -1432,7 +1432,7 @@ void Label::enableBold()
if (!_boldEnabled)
{
// bold is implemented with outline
enableShadow(Color4B::WHITE, Size(0.9f, 0), 0);
enableShadow(Color4B::WHITE, Vec2(0.9f, 0), 0);
// add one to kerning
setAdditionalKerning(_additionalKerning+1);
_boldEnabled = true;
@ -2331,7 +2331,7 @@ std::string Label::getDescription() const
return ret;
}
const Size& Label::getContentSize() const
const Vec2& Label::getContentSize() const
{
if (_systemFontDirty || _contentDirty)
{

View File

@ -158,7 +158,7 @@ public:
* @return An automatically released Label object.
*/
static Label* createWithSystemFont(const std::string& text, const std::string& font, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
const Vec2& dimensions = Vec2::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);
/**
@ -174,7 +174,7 @@ public:
* @return An automatically released Label object.
*/
static Label * createWithTTF(const std::string& text, const std::string& fontFilePath, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
const Vec2& dimensions = Vec2::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);
/**
@ -396,7 +396,7 @@ public:
*
* @todo Support blur for shadow effect.
*/
virtual void enableShadow(const Color4B& shadowColor = Color4B::BLACK,const Size &offset = Size(2,-2), int blurRadius = 0);
virtual void enableShadow(const Color4B& shadowColor = Color4B::BLACK,const Vec2 &offset = Vec2(2,-2), int blurRadius = 0);
/**
* Enable outline effect to Label.
@ -452,7 +452,7 @@ public:
/**
* Return shadow effect offset value.
*/
Size getShadowOffset() const { return _shadowOffset; }
Vec2 getShadowOffset() const { return _shadowOffset; }
/**
* Return the shadow effect blur radius.
@ -576,7 +576,7 @@ public:
/** Sets the untransformed size of the Label in a more efficient way. */
void setDimensions(float width, float height);
const Size& getDimensions() const{ return _labelDimensions;}
const Vec2& getDimensions() const{ return _labelDimensions;}
/** Update content immediately.*/
virtual void updateContent();
@ -652,7 +652,7 @@ public:
virtual std::string getDescription() const override;
virtual const Size& getContentSize() const override;
virtual const Vec2& getContentSize() const override;
virtual Rect getBoundingBox() const override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
@ -680,7 +680,7 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Label();
bool initWithTTF(const std::string& text, const std::string& fontFilePath, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
const Vec2& dimensions = Vec2::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);
bool initWithTTF(const TTFConfig& ttfConfig, const std::string& text,
@ -804,7 +804,7 @@ protected:
int* _horizontalKernings;
bool _lineBreakWithoutSpaces;
float _maxLineWidth;
Size _labelDimensions;
Vec2 _labelDimensions;
float _labelWidth;
float _labelHeight;
TextHAlignment _hAlignment;
@ -835,7 +835,7 @@ protected:
bool _shadowDirty;
bool _shadowEnabled;
Size _shadowOffset;
Vec2 _shadowOffset;
Color4F _shadowColor4F;
Color3B _shadowColor3B;

View File

@ -220,7 +220,7 @@ void LabelAtlas::setString(const std::string &label)
_string = label;
this->updateAtlasValues();
Size s = Size(len * _itemWidth, _itemHeight);
Vec2 s = Vec2(len * _itemWidth, _itemHeight);
this->setContentSize(s);

View File

@ -295,7 +295,7 @@ bool Label::multilineTextWrap(const std::function<int(const std::u32string&, int
_textDesiredHeight = (_numberOfLines * _lineHeight * _bmfontScale) / contentScaleFactor;
if (_numberOfLines > 1)
_textDesiredHeight += (_numberOfLines - 1) * _lineSpacing;
Size contentSize(_labelWidth, _labelHeight);
Vec2 contentSize(_labelWidth, _labelHeight);
if (_labelWidth <= 0.f)
contentSize.width = longestLine;
if (_labelHeight <= 0.f)

View File

@ -185,7 +185,7 @@ LayerColor * LayerColor::create(const Color4B& color)
bool LayerColor::init()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
return initWithColor(Color4B(0,0,0,0), s.width, s.height);
}
@ -209,7 +209,7 @@ bool LayerColor::initWithColor(const Color4B& color, float w, float h)
}
updateColor();
setContentSize(Size(w, h));
setContentSize(Vec2(w, h));
return true;
}
@ -218,12 +218,12 @@ bool LayerColor::initWithColor(const Color4B& color, float w, float h)
bool LayerColor::initWithColor(const Color4B& color)
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
return initWithColor(color, s.width, s.height);
}
/// override contentSize
void LayerColor::setContentSize(const Size & size)
void LayerColor::setContentSize(const Vec2 & size)
{
_squareVertices[1].x = size.width;
_squareVertices[2].y = size.height;
@ -235,17 +235,17 @@ void LayerColor::setContentSize(const Size & size)
void LayerColor::changeWidthAndHeight(float w ,float h)
{
this->setContentSize(Size(w, h));
this->setContentSize(Vec2(w, h));
}
void LayerColor::changeWidth(float w)
{
this->setContentSize(Size(w, _contentSize.height));
this->setContentSize(Vec2(w, _contentSize.height));
}
void LayerColor::changeHeight(float h)
{
this->setContentSize(Size(_contentSize.width, h));
this->setContentSize(Vec2(_contentSize.width, h));
}
void LayerColor::updateColor()
@ -587,7 +587,7 @@ void LayerRadialGradient::draw(Renderer *renderer, const Mat4 &transform, uint32
programState->setUniform(_expandLocation, &_expand, sizeof(_expand));
}
void LayerRadialGradient::setContentSize(const Size& size)
void LayerRadialGradient::setContentSize(const Vec2& size)
{
_vertices[1].x = size.width;
_vertices[2].y = size.height;

View File

@ -131,7 +131,7 @@ public:
//
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void setContentSize(const Size & var) override;
virtual void setContentSize(const Vec2 & var) override;
/** BlendFunction. Conforms to BlendProtocol protocol */
/**
* @lua NA
@ -341,7 +341,7 @@ public:
// overrides
//
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void setContentSize(const Size& size) override;
virtual void setContentSize(const Vec2& size) override;
void setStartOpacity(uint8_t opacity);
uint8_t getStartOpacity() const;

View File

@ -119,7 +119,7 @@ bool Menu::initWithArray(const Vector<MenuItem*>& arrayOfItems)
{
_enabled = true;
// menu in the center of the screen
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
this->setIgnoreAnchorPointForPosition(true);
setAnchorPoint(Vec2(0.5f, 0.5f));
@ -385,7 +385,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows)
// check if too many rows/columns for available menu items
CCASSERT(! columnsOccupied, "columnsOccupied should be 0.");
Size winSize = getContentSize();
Vec2 winSize = getContentSize();
row = 0;
rowHeight = 0;
@ -487,7 +487,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
// check if too many rows/columns for available menu items.
CCASSERT(! rowsOccupied, "rowsOccupied should be 0.");
Size winSize = getContentSize();
Vec2 winSize = getContentSize();
column = 0;
columnWidth = 0;

View File

@ -789,7 +789,7 @@ void MenuItemToggle::setSelectedIndex(unsigned int index)
_selectedItem = _subItems.at(_selectedIndex);
this->addChild(_selectedItem);
Size s = _selectedItem->getContentSize();
Vec2 s = _selectedItem->getContentSize();
this->setContentSize(s);
_selectedItem->setPosition(s.width / 2, s.height / 2);
}

View File

@ -76,7 +76,7 @@ Node::Node()
, _skewX(0.0f)
, _skewY(0.0f)
, _anchorPoint(0, 0)
, _contentSize(Size::ZERO)
, _contentSize(Vec2::ZERO)
, _contentSizeDirty(true)
, _transformDirty(true)
, _inverseDirty(true)
@ -620,12 +620,12 @@ void Node::setAnchorPoint(const Vec2& point)
}
/// contentSize getter
const Size& Node::getContentSize() const
const Vec2& Node::getContentSize() const
{
return _contentSize;
}
void Node::setContentSize(const Size & size)
void Node::setContentSize(const Vec2 & size)
{
if (! size.equals(_contentSize))
{

View File

@ -326,7 +326,7 @@ public:
* Usually we use `Vec2(x,y)` to compose Vec2 object.
* This code snippet sets the node in the center of screen.
@code
Size size = Director::getInstance()->getWinSize();
Vec2 size = Director::getInstance()->getWinSize();
node->setPosition(size.width/2, size.height/2);
@endcode
*
@ -339,7 +339,7 @@ public:
@code
// pseudo code
void setNormalizedPosition(Vec2 pos) {
Size s = getParent()->getContentSize();
Vec2 s = getParent()->getContentSize();
_position = pos * s;
}
@endcode
@ -552,15 +552,15 @@ public:
*
* @param contentSize The untransformed size of the node.
*/
virtual void setContentSize(const Size& contentSize);
virtual void setContentSize(const Vec2& contentSize);
/**
* Returns the untransformed size of the node.
*
* @see `setContentSize(const Size&)`
* @see `setContentSize(const Vec2&)`
*
* @return The untransformed size of the node.
*/
virtual const Size& getContentSize() const;
virtual const Vec2& getContentSize() const;
/**
@ -1866,7 +1866,7 @@ protected:
Vec2 _anchorPointInPoints; ///< anchor point in points
Vec2 _anchorPoint; ///< anchor point normalized (NOT in points)
Size _contentSize; ///< untransformed size of the node
Vec2 _contentSize; ///< untransformed size of the node
Mat4 _modelViewTransform; ///< ModelView transform of the Node.
// "cache" variables are allowed to be mutable

View File

@ -113,7 +113,7 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
_angleVar = 10;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2.0f, 60.0f);
this->_posVar.set(40.0f, 20.0f);
@ -214,7 +214,7 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles)
this->modeA.speedVar = 50.0f;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height/2);
// angle
@ -323,7 +323,7 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height/2);
setPosVar(Vec2::ZERO);
@ -430,7 +430,7 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height/2);
setPosVar(Vec2::ZERO);
@ -539,7 +539,7 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height/2);
setPosVar(Vec2::ZERO);
@ -647,7 +647,7 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height/2);
setPosVar(Vec2::ZERO);
@ -756,7 +756,7 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
_angleVar = 0;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height/2);
setPosVar(Vec2::ZERO);
@ -864,7 +864,7 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles)
_angleVar = 360;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height/2);
setPosVar(Vec2::ZERO);
@ -969,7 +969,7 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles)
_angleVar = 5;
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, 0);
setPosVar(Vec2(20, 0));
@ -1074,7 +1074,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
setTangentialAccelVar(1);
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height + 10);
setPosVar(Vec2(winSize.width/2, 0.0f));
@ -1186,7 +1186,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
// emitter position
Size winSize = _director->getWinSize();
Vec2 winSize = _director->getWinSize();
this->setPosition(winSize.width/2, winSize.height);
setPosVar(Vec2(winSize.width/2, 0.0f));

View File

@ -222,7 +222,7 @@ void ParticleSystemQuad::updateTexCoords()
{
if (_texture)
{
const Size& s = _texture->getContentSize();
const Vec2& s = _texture->getContentSize();
initTexCoordsWithRect(Rect(0, 0, s.width, s.height));
}
}
@ -243,7 +243,7 @@ void ParticleSystemQuad::setTextureWithRect(Texture2D *texture, const Rect& rect
void ParticleSystemQuad::setTexture(Texture2D* texture)
{
const Size& s = texture->getContentSize();
const Vec2& s = texture->getContentSize();
this->setTextureWithRect(texture, Rect(0, 0, s.width, s.height));
}

View File

@ -170,7 +170,7 @@ void PlistSpriteSheetLoader::addSpriteFramesWithDictionary(ValueMap& dictionary,
auto& framesDict = dictionary["frames"].asValueMap();
int format = 0;
Size textureSize;
Vec2 textureSize;
// get the format
auto metaItr = dictionary.find("metadata");
@ -225,7 +225,7 @@ void PlistSpriteSheetLoader::addSpriteFramesWithDictionary(ValueMap& dictionary,
Rect(x, y, w, h),
false,
Vec2(ox, oy),
Size((float)ow, (float)oh)
Vec2((float)ow, (float)oh)
);
}
else if (format == 1 || format == 2)
@ -428,7 +428,7 @@ void PlistSpriteSheetLoader::reloadSpriteFramesWithDictionary(ValueMap& dict, Te
Rect(x, y, w, h),
false,
Vec2(ox, oy),
Size((float)ow, (float)oh)
Vec2((float)ow, (float)oh)
);
}
else if (format == 1 || format == 2)

View File

@ -77,7 +77,7 @@ void RenderTexture::listenToBackground(EventCustom* /*event*/)
CC_SAFE_RELEASE(_UITextureImage);
_UITextureImage = uiTextureImage;
CC_SAFE_RETAIN(_UITextureImage);
const Size& s = _texture2D->getContentSizeInPixels();
const Vec2& s = _texture2D->getContentSizeInPixels();
VolatileTextureMgr::addDataTexture(_texture2D, uiTextureImage->getData(), s.width * s.height * 4, backend::PixelFormat::RGBA8, s);
if ( _texture2DCopy )
@ -100,7 +100,7 @@ void RenderTexture::listenToBackground(EventCustom* /*event*/)
void RenderTexture::listenToForeground(EventCustom* /*event*/)
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
const Size& s = _texture2D->getContentSizeInPixels();
const Vec2& s = _texture2D->getContentSizeInPixels();
//TODO new-renderer: field _depthAndStencilFormat removal
// if (_depthAndStencilFormat != 0)
// {
@ -458,7 +458,7 @@ void RenderTexture::newImage(std::function<void(RefPtr<Image>)> imageCallback, b
return ;
}
const Size& s = _texture2D->getContentSizeInPixels();
const Vec2& s = _texture2D->getContentSizeInPixels();
// to get the image size to save
// if the saving image domain exceeds the buffer texture domain,
@ -511,10 +511,10 @@ void RenderTexture::onBegin()
if(!_keepMatrix)
{
_director->setProjection(_director->getProjection());
const Size& texSize = _texture2D->getContentSizeInPixels();
const Vec2& texSize = _texture2D->getContentSizeInPixels();
// Calculate the adjustment ratios based on the old and new projections
Size size = _director->getWinSizeInPixels();
Vec2 size = _director->getWinSizeInPixels();
float widthRatio = size.width / texSize.width;
float heightRatio = size.height / texSize.height;
@ -563,10 +563,10 @@ void RenderTexture::begin()
{
_director->setProjection(_director->getProjection());
const Size& texSize = _texture2D->getContentSizeInPixels();
const Vec2& texSize = _texture2D->getContentSizeInPixels();
// Calculate the adjustment ratios based on the old and new projections
Size size = _director->getWinSizeInPixels();
Vec2 size = _director->getWinSizeInPixels();
float widthRatio = size.width / texSize.width;
float heightRatio = size.height / texSize.height;

View File

@ -103,7 +103,7 @@ bool Scene::init()
return initWithSize(size);
}
bool Scene::initWithSize(const Size& size)
bool Scene::initWithSize(const Vec2& size)
{
initDefaultCamera();
setContentSize(size);
@ -132,7 +132,7 @@ Scene* Scene::create()
}
}
Scene* Scene::createWithSize(const Size& size)
Scene* Scene::createWithSize(const Vec2& size)
{
Scene *ret = new (std::nothrow) Scene();
if (ret && ret->initWithSize(size))

View File

@ -76,13 +76,13 @@ public:
*/
static Scene *create();
/** Creates a new Scene object with a predefined Size.
/** Creates a new Scene object with a predefined Vec2.
*
* @param size The predefined size of scene.
* @return An autoreleased Scene object.
* @js NA
*/
static Scene *createWithSize(const Size& size);
static Scene *createWithSize(const Vec2& size);
using Node::addChild;
virtual std::string getDescription() const override;
@ -122,7 +122,7 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Scene();
bool init() override;
bool initWithSize(const Size& size);
bool initWithSize(const Vec2& size);
void setCameraOrderDirty() { _cameraOrderDirty = true; }

View File

@ -450,7 +450,7 @@ void Sprite::setTextureRect(const Rect& rect)
setTextureRect(rect, false, rect.size);
}
void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize)
void Sprite::setTextureRect(const Rect& rect, bool rotated, const Vec2& untrimmedSize)
{
_rectRotated = rotated;
@ -769,7 +769,7 @@ void Sprite::setCenterRect(const cocos2d::Rect &rectInPoints)
return;
}
if (!_originalContentSize.equals(Size::ZERO))
if (!_originalContentSize.equals(Vec2::ZERO))
{
Rect rect = rectInPoints;
@ -1022,7 +1022,7 @@ void Sprite::updateTransform()
// calculate the Quad based on the Affine Matrix
//
Size &size = _rect.size;
Vec2 &size = _rect.size;
float x1 = _offsetPosition.x;
float y1 = _offsetPosition.y;
@ -1363,7 +1363,7 @@ void Sprite::setVisible(bool bVisible)
SET_DIRTY_RECURSIVELY();
}
void Sprite::setContentSize(const Size& size)
void Sprite::setContentSize(const Vec2& size)
{
if (_renderMode == RenderMode::QUAD_BATCHNODE || _renderMode == RenderMode::POLYGON)
CCLOGWARN("Sprite::setContentSize() doesn't stretch the sprite when using QUAD_BATCHNODE or POLYGON render modes");
@ -1396,7 +1396,7 @@ bool Sprite::isStretchEnabled() const
void Sprite::updateStretchFactor()
{
const Size size = getContentSize();
const Vec2 size = getContentSize();
if (_renderMode == RenderMode::QUAD)
{

View File

@ -42,7 +42,7 @@ class SpriteBatchNode;
class SpriteFrame;
class Animation;
class Rect;
class Size;
class Vec2;
class Texture2D;
struct transformValues_;
@ -243,7 +243,7 @@ public:
/**
* Updates the texture rect of the Sprite in points.
*
* It will call setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize) with \p rotated = false, and \p utrimmedSize = rect.size.
* It will call setTextureRect(const Rect& rect, bool rotated, const Vec2& untrimmedSize) with \p rotated = false, and \p utrimmedSize = rect.size.
*/
virtual void setTextureRect(const Rect& rect);
@ -251,7 +251,7 @@ public:
*
* It will update the texture coordinates and the vertex rectangle.
*/
virtual void setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize);
virtual void setTextureRect(const Rect& rect, bool rotated, const Vec2& untrimmedSize);
/**
* Sets the vertex rect.
@ -373,7 +373,7 @@ public:
virtual void setScale(float scale) override;
virtual void setPositionZ(float positionZ) override;
virtual void setAnchorPoint(const Vec2& anchor) override;
virtual void setContentSize(const Size& size) override;
virtual void setContentSize(const Vec2& size) override;
virtual void setIgnoreAnchorPointForPosition(bool value) override;
@ -671,7 +671,7 @@ protected:
Rect _centerRectNormalized = {0,0,1,1}; /// Rectangle to implement "slice 9"
RenderMode _renderMode = Sprite::RenderMode::QUAD; /// render mode used by the Sprite: Quad, Slice9, Polygon or Quad_Batchnode
Vec2 _stretchFactor = Vec2::ONE; /// stretch factor to match the contentSize. for 1- and 9- slice sprites
Size _originalContentSize = Size::ZERO; /// original content size
Vec2 _originalContentSize = Vec2::ZERO; /// original content size
// Offset Position (used by Zwoptex)

View File

@ -53,7 +53,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D *texture, const Rect& rect
return spriteFrame;
}
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize)
{
SpriteFrame *spriteFrame = new (std::nothrow) SpriteFrame();
if (spriteFrame && spriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize)) {
@ -65,7 +65,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect
return nullptr;
}
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize)
{
SpriteFrame *spriteFrame = new (std::nothrow) SpriteFrame();
if (spriteFrame && spriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize)) {
@ -94,7 +94,7 @@ bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rec
return initWithTextureFilename(filename, rectInPixels, false, Vec2::ZERO, rectInPixels.size);
}
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize)
{
_texture = texture;
@ -116,7 +116,7 @@ bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rot
return true;
}
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize)
{
if (FileUtils::getInstance()->isFileExist(filename)) {
_texture = nullptr;

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
#include "2d/CCNode.h"
#include "2d/CCAutoPolygon.h"
#include "base/CCRef.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
NS_CC_BEGIN
@ -79,7 +79,7 @@ public:
* @param originalSize A specified original size.
* @return An autoreleased SpriteFrame object.
*/
static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize);
/** Create a SpriteFrame with a texture, rect in points.
It is assumed that the frame was not trimmed.
@ -98,7 +98,7 @@ public:
* @param originalSize A specified original size.
* @return An autoreleased SpriteFrame object.
*/
static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize);
// attributes
/** Get rect of the sprite frame.
@ -176,23 +176,23 @@ public:
*
* @return The original size of the trimmed image, in pixels.
*/
const Size& getOriginalSizeInPixels() const { return _originalSizeInPixels; }
const Vec2& getOriginalSizeInPixels() const { return _originalSizeInPixels; }
/** Set original size of the trimmed image.
*
* @param sizeInPixels The original size of the trimmed image, in pixels.
*/
void setOriginalSizeInPixels(const Size& sizeInPixels) { _originalSizeInPixels = sizeInPixels; }
void setOriginalSizeInPixels(const Vec2& sizeInPixels) { _originalSizeInPixels = sizeInPixels; }
/** Get original size of the trimmed image.
*
* @return The original size of the trimmed image.
*/
const Size& getOriginalSize() const { return _originalSize; }
const Vec2& getOriginalSize() const { return _originalSize; }
/** Set original size of the trimmed image.
*
* @param sizeInPixels The original size of the trimmed image.
*/
void setOriginalSize(const Size& sizeInPixels) { _originalSize = sizeInPixels; }
void setOriginalSize(const Vec2& sizeInPixels) { _originalSize = sizeInPixels; }
/** Get texture of the frame.
*
@ -277,25 +277,25 @@ CC_CONSTRUCTOR_ACCESS:
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in points of the frame before being trimmed.
*/
bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize);
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in pixels of the frame before being trimmed.
@since v1.1
*/
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Vec2& originalSize);
protected:
Vec2 _offset;
Vec2 _anchorPoint;
Size _originalSize;
Vec2 _originalSize;
Rect _rectInPixels;
bool _rotated;
Rect _rect;
Rect _centerRect;
Vec2 _offsetInPixels;
Size _originalSizeInPixels;
Vec2 _originalSizeInPixels;
Texture2D *_texture;
std::string _textureFilename;
PolygonInfo _polygonInfo;

View File

@ -6,8 +6,8 @@ using namespace std;
NS_CC_BEGIN
void SpriteSheetLoader::initializePolygonInfo(const Size& textureSize,
const Size& spriteSize,
void SpriteSheetLoader::initializePolygonInfo(const Vec2& textureSize,
const Vec2& spriteSize,
const std::vector<int>& vertices,
const std::vector<int>& verticesUV,
const std::vector<int>& triangleIndices,

View File

@ -83,8 +83,8 @@ class SpriteSheetLoader : public ISpriteSheetLoader
{
public:
/** Configures PolygonInfo class with the passed sizes + triangles */
void initializePolygonInfo(const Size& textureSize,
const Size& spriteSize,
void initializePolygonInfo(const Vec2& textureSize,
const Vec2& spriteSize,
const std::vector<int>& vertices,
const std::vector<int>& verticesUV,
const std::vector<int>& triangleIndices,

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
#ifndef __CCTMX_OBJECT_GROUP_H__
#define __CCTMX_OBJECT_GROUP_H__
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "base/CCValue.h"
#include "base/CCRef.h"

View File

@ -71,10 +71,10 @@ void TMXLayerInfo::setProperties(ValueMap var)
// implementation TMXTilesetInfo
TMXTilesetInfo::TMXTilesetInfo()
:_firstGid(0)
,_tileSize(Size::ZERO)
,_tileSize(Vec2::ZERO)
,_spacing(0)
,_margin(0)
,_imageSize(Size::ZERO)
,_imageSize(Vec2::ZERO)
{
}
@ -166,8 +166,8 @@ TMXMapInfo::TMXMapInfo()
, _staggerAxis(TMXStaggerAxis_Y)
, _staggerIndex(TMXStaggerIndex_Even)
, _hexSideLength(0)
, _mapSize(Size::ZERO)
, _tileSize(Size::ZERO)
, _mapSize(Vec2::ZERO)
, _tileSize(Vec2::ZERO)
, _parentElement(0)
, _parentGID(0)
, _layerAttribs(0)
@ -272,7 +272,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
float hexSideLength = attributeDict["hexsidelength"].asFloat();
tmxMapInfo->setHexSideLength(hexSideLength);
Size s;
Vec2 s;
s.width = attributeDict["width"].asFloat();
s.height = attributeDict["height"].asFloat();
tmxMapInfo->setMapSize(s);
@ -338,7 +338,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
tileset->_spacing = attributeDict["spacing"].asInt();
tileset->_margin = attributeDict["margin"].asInt();
Size s;
Vec2 s;
s.width = attributeDict["tilewidth"].asFloat();
s.height = attributeDict["tileheight"].asFloat();
tileset->_tileSize = s;
@ -352,7 +352,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
if (tmxMapInfo->getParentElement() == TMXPropertyLayer)
{
TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
Size layerSize = layer->_layerSize;
Vec2 layerSize = layer->_layerSize;
uint32_t gid = static_cast<uint32_t>(attributeDict["gid"].asUnsignedInt());
int tilesAmount = layerSize.width*layerSize.height;
@ -374,7 +374,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
TMXLayerInfo *layer = new (std::nothrow) TMXLayerInfo();
layer->_name = attributeDict["name"].asString();
Size s;
Vec2 s;
s.width = attributeDict["width"].asFloat();
s.height = attributeDict["height"].asFloat();
layer->_layerSize = s;
@ -449,7 +449,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
tmxMapInfo->setLayerAttribs(tmxMapInfo->getLayerAttribs() | TMXLayerAttribNone);
TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
Size layerSize = layer->_layerSize;
Vec2 layerSize = layer->_layerSize;
int tilesAmount = layerSize.width*layerSize.height;
uint32_t *tiles = (uint32_t*) malloc(tilesAmount*sizeof(uint32_t));
@ -512,7 +512,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
int width = attributeDict["width"].asInt();
int height = attributeDict["height"].asInt();
Size s(width, height);
Vec2 s(width, height);
s = CC_SIZE_PIXELS_TO_POINTS(s);
dict["width"] = Value(s.width);
dict["height"] = Value(s.height);
@ -703,7 +703,7 @@ void TMXMapInfo::endElement(void* /*ctx*/, const char *name)
if (tmxMapInfo->getLayerAttribs() & (TMXLayerAttribGzip | TMXLayerAttribZlib))
{
unsigned char *deflated = nullptr;
Size s = layer->_layerSize;
Vec2 s = layer->_layerSize;
// int sizeHint = s.width * s.height * sizeof(uint32_t);
ssize_t sizeHint = s.width * s.height * sizeof(unsigned int);

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
/// @cond DO_NOT_SHOW
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "platform/CCSAXParser.h"
#include "base/CCVector.h"
#include "base/CCMap.h"
@ -184,7 +184,7 @@ public:
ValueMap _properties;
std::string _name;
Size _layerSize;
Vec2 _layerSize;
uint32_t *_tiles;
bool _visible;
unsigned char _opacity;
@ -207,14 +207,14 @@ class CC_DLL TMXTilesetInfo : public Ref
public:
std::string _name;
int _firstGid;
Size _tileSize;
Vec2 _tileSize;
int _spacing;
int _margin;
Vec2 _tileOffset;
//! filename containing the tiles (should be spritesheet / texture atlas)
std::string _sourceImage;
//! size in pixels of the image
Size _imageSize;
Vec2 _imageSize;
std::string _originSourceImage;
//! map from gid of animated tile to its animation info
Map<uint32_t, TMXTileAnimInfo*> _animationInfo;
@ -293,12 +293,12 @@ public:
void setHexSideLength(int hexSideLength) { _hexSideLength = hexSideLength; }
/// map width & height
const Size& getMapSize() const { return _mapSize; }
void setMapSize(const Size& mapSize) { _mapSize = mapSize; }
const Vec2& getMapSize() const { return _mapSize; }
void setMapSize(const Vec2& mapSize) { _mapSize = mapSize; }
/// tiles width & height
const Size& getTileSize() const { return _tileSize; }
void setTileSize(const Size& tileSize) { _tileSize = tileSize; }
const Vec2& getTileSize() const { return _tileSize; }
void setTileSize(const Vec2& tileSize) { _tileSize = tileSize; }
/// Layers
const Vector<TMXLayerInfo*>& getLayers() const { return _layers; }
@ -379,9 +379,9 @@ protected:
///map hexsidelength
int _hexSideLength;
/// map width & height
Size _mapSize;
Vec2 _mapSize;
/// tiles width & height
Size _tileSize;
Vec2 _tileSize;
/// Layers
Vector<TMXLayerInfo*> _layers;
/// tilesets

View File

@ -108,7 +108,7 @@ TextFieldTTF::~TextFieldTTF()
// static constructor
//////////////////////////////////////////////////////////////////////////
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const Vec2& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
{
TextFieldTTF *ret = new (std::nothrow) TextFieldTTF();
if(ret && ret->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
@ -144,7 +144,7 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeho
// initialize
//////////////////////////////////////////////////////////////////////////
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Vec2& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
{
setDimensions(dimensions.width, dimensions.height);
setAlignment(alignment, TextVAlignment::CENTER);
@ -387,7 +387,7 @@ void TextFieldTTF::setCursorFromPoint(const Vec2 &point, const Camera* camera)
auto sprite = getLetter(latterPosition);
if (sprite)
{
rect.size = Size(sprite->getContentSize().width, _lineHeight);
rect.size = Vec2(sprite->getContentSize().width, _lineHeight);
if (isScreenPointInRect(point, camera, sprite->getWorldToNodeTransform(), rect, nullptr))
{
setCursorPosition(latterPosition);

View File

@ -99,7 +99,7 @@ public:
/** Creates a TextFieldTTF from a fontname, alignment, dimension and font size.
* @js NA
*/
static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const Vec2& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
/** Creates a TextFieldTTF from a fontname and font size.
* @js NA
@ -107,7 +107,7 @@ public:
static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize);
/** Initializes the TextFieldTTF with a font name, alignment, dimension and font size. */
bool initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
bool initWithPlaceHolder(const std::string& placeholder, const Vec2& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
/** Initializes the TextFieldTTF with a font name and font size. */
bool initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize);

View File

@ -56,7 +56,7 @@ bool TileMapAtlas::initWithTileFile(const std::string& tile, const std::string&
if( AtlasNode::initWithTileFile(tile, tileWidth, tileHeight, _itemsToRender) )
{
this->updateAtlasValues();
this->setContentSize(Size((float)(_TGAInfo->width*_itemWidth),
this->setContentSize(Vec2((float)(_TGAInfo->width*_itemWidth),
(float)(_TGAInfo->height*_itemHeight)));
return true;
}

View File

@ -328,7 +328,7 @@ TransitionJumpZoom* TransitionJumpZoom::create(float t, Scene* scene)
void TransitionJumpZoom::onEnter()
{
TransitionScene::onEnter();
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setScale(0.5f);
_inScene->setPosition(s.width, 0);
@ -411,7 +411,7 @@ ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
void TransitionMoveInL::initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(-s.width,0);
}
@ -439,7 +439,7 @@ TransitionMoveInR* TransitionMoveInR::create(float t, Scene* scene)
void TransitionMoveInR::initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(s.width,0);
}
@ -467,7 +467,7 @@ TransitionMoveInT* TransitionMoveInT::create(float t, Scene* scene)
void TransitionMoveInT::initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(0,s.height);
}
@ -495,7 +495,7 @@ TransitionMoveInB* TransitionMoveInB::create(float t, Scene* scene)
void TransitionMoveInB::initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(0,-s.height);
}
@ -543,13 +543,13 @@ void TransitionSlideInL::sceneOrder()
void TransitionSlideInL:: initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(-(s.width-ADJUST_FACTOR),0.0f);
}
ActionInterval* TransitionSlideInL::action()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0.0f));
}
@ -599,14 +599,14 @@ void TransitionSlideInR::sceneOrder()
void TransitionSlideInR::initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(s.width-ADJUST_FACTOR,0);
}
ActionInterval* TransitionSlideInR:: action()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0.0f));
}
@ -640,14 +640,14 @@ void TransitionSlideInT::sceneOrder()
void TransitionSlideInT::initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(0,s.height-ADJUST_FACTOR);
}
ActionInterval* TransitionSlideInT::action()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
return MoveBy::create(_duration, Vec2(0.0f,-(s.height-ADJUST_FACTOR)));
}
@ -680,14 +680,14 @@ void TransitionSlideInB::sceneOrder()
void TransitionSlideInB:: initScenes()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
_inScene->setPosition(0,-(s.height-ADJUST_FACTOR));
}
ActionInterval* TransitionSlideInB:: action()
{
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
return MoveBy::create(_duration, Vec2(0.0f,s.height-ADJUST_FACTOR));
}
@ -1288,7 +1288,7 @@ void TransitionCrossFade::onEnter()
// create a transparent color layer
// in which we are going to add our rendertextures
Color4B color(0,0,0,0);
Size size = _director->getWinSize();
Vec2 size = _director->getWinSize();
LayerColor* layer = LayerColor::create(color);
// create the first render texture for inScene
@ -1396,12 +1396,12 @@ void TransitionTurnOffTiles::onEnter()
_outSceneProxy->setTarget(_outScene);
_outSceneProxy->onEnter();
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
float aspect = s.width / s.height;
int x = (int)(12 * aspect);
int y = 12;
TurnOffTiles* toff = TurnOffTiles::create(_duration, Size(x,y));
TurnOffTiles* toff = TurnOffTiles::create(_duration, Vec2(x,y));
ActionInterval* action = easeActionWithAction(toff);
_outSceneProxy->runAction
(
@ -1592,12 +1592,12 @@ void TransitionFadeTR::onEnter()
_outSceneProxy->setTarget(_outScene);
_outSceneProxy->onEnter();
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
float aspect = s.width / s.height;
int x = (int)(12 * aspect);
int y = 12;
ActionInterval* action = actionWithSize(Size(x,y));
ActionInterval* action = actionWithSize(Vec2(x,y));
_outSceneProxy->runAction
(
@ -1634,7 +1634,7 @@ void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, uint32_t
}
}
ActionInterval* TransitionFadeTR::actionWithSize(const Size& size)
ActionInterval* TransitionFadeTR::actionWithSize(const Vec2& size)
{
return FadeOutTRTiles::create(_duration, size);
}
@ -1668,7 +1668,7 @@ TransitionFadeBL* TransitionFadeBL::create(float t, Scene* scene)
return nullptr;
}
ActionInterval* TransitionFadeBL::actionWithSize(const Size& size)
ActionInterval* TransitionFadeBL::actionWithSize(const Vec2& size)
{
return FadeOutBLTiles::create(_duration, size);
}
@ -1696,7 +1696,7 @@ TransitionFadeUp* TransitionFadeUp::create(float t, Scene* scene)
return nullptr;
}
ActionInterval* TransitionFadeUp::actionWithSize(const Size& size)
ActionInterval* TransitionFadeUp::actionWithSize(const Vec2& size)
{
return FadeOutUpTiles::create(_duration, size);
}
@ -1723,7 +1723,7 @@ TransitionFadeDown* TransitionFadeDown::create(float t, Scene* scene)
return nullptr;
}
ActionInterval* TransitionFadeDown::actionWithSize(const Size& size)
ActionInterval* TransitionFadeDown::actionWithSize(const Vec2& size)
{
return FadeOutDownTiles::create(_duration, size);
}

View File

@ -972,7 +972,7 @@ public:
* @param size A given size.
* @return The action that will be performed.
*/
virtual ActionInterval* actionWithSize(const Size& size);
virtual ActionInterval* actionWithSize(const Vec2& size);
//
// Overrides
@ -1017,7 +1017,7 @@ public:
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
virtual ActionInterval* actionWithSize(const Vec2& size) override;
CC_CONSTRUCTOR_ACCESS:
TransitionFadeBL();
@ -1045,7 +1045,7 @@ public:
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
virtual ActionInterval* actionWithSize(const Vec2& size) override;
CC_CONSTRUCTOR_ACCESS:
TransitionFadeUp();
@ -1073,7 +1073,7 @@ public:
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
virtual ActionInterval* actionWithSize(const Vec2& size) override;
CC_CONSTRUCTOR_ACCESS:
TransitionFadeDown();

View File

@ -99,7 +99,7 @@ void TransitionPageTurn::onEnter()
_inSceneProxy->onEnter();
_outSceneProxy->onEnter();
Size s = _director->getWinSize();
Vec2 s = _director->getWinSize();
int x,y;
if (s.width > s.height)
{
@ -112,7 +112,7 @@ void TransitionPageTurn::onEnter()
y=16;
}
ActionInterval *action = this->actionWithSize(Size(x,y));
ActionInterval *action = this->actionWithSize(Vec2(x,y));
if (! _back )
{
@ -154,7 +154,7 @@ void TransitionPageTurn::onExit()
TransitionScene::onExit();
}
ActionInterval* TransitionPageTurn:: actionWithSize(const Size& vector)
ActionInterval* TransitionPageTurn:: actionWithSize(const Vec2& vector)
{
if (_back)
{

View File

@ -89,7 +89,7 @@ public:
* @param vector A given size.
* @return The action that will be performed.
*/
ActionInterval* actionWithSize(const Size& vector);
ActionInterval* actionWithSize(const Vec2& vector);
//
// Overrides

View File

@ -1456,7 +1456,8 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
int the_index = -1;
const rapidjson::Value& animation_data_array = _jsonReader[anim.c_str()];
if (animation_data_array.Size()==0) return false;
if (animation_data_array.Size() == 0)
return false;
if(!id.empty())
{
@ -1477,7 +1478,7 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
animationdata->_totalTime = animation_data_array_val_0[LENGTH].GetFloat();
const rapidjson::Value& bones = animation_data_array_val_0[BONES];
for (rapidjson::SizeType i = 0; i < bones.Size(); ++i)
for (rapidjson::SizeType i = 0; i < bones.Size(); ++i)
{
const rapidjson::Value& bone = bones[i];
std::string bone_name = bone[BONEID].GetString();
@ -1485,7 +1486,7 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
if ( bone.HasMember(KEYFRAMES))
{
const rapidjson::Value& bone_keyframes = bone[KEYFRAMES];
rapidjson::SizeType keyframe_size = bone_keyframes.Size();
rapidjson::SizeType keyframe_size = bone_keyframes.Size();
animationdata->_rotationKeys[bone_name].reserve(keyframe_size);
animationdata->_scaleKeys[bone_name].reserve(keyframe_size);
animationdata->_translationKeys[bone_name].reserve(keyframe_size);

View File

@ -1589,7 +1589,7 @@ Terrain::QuadTree::~QuadTree()
if (_br) delete _br;
}
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& textureSrc, const Size & chunksize, float height, float scale)
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& textureSrc, const Vec2 & chunksize, float height, float scale)
{
this->_heightMapSrc = heightMapsrc;
this->_detailMaps[0]._detailMapSrc = textureSrc;
@ -1600,7 +1600,7 @@ Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::st
_skirtHeightRatio = 1;
}
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Size & chunksize, float height, float scale)
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Vec2 & chunksize, float height, float scale)
{
this->_heightMapSrc = heightMapsrc;
this->_alphaMapSrc = alphamap;
@ -1615,7 +1615,7 @@ Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::st
_skirtHeightRatio = 1;
}
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const Size & chunksize /*= Size(32,32)*/, float height /*= 2*/, float scale /*= 0.1*/)
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const Vec2 & chunksize /*= Vec2(32,32)*/, float height /*= 2*/, float scale /*= 0.1*/)
{
this->_heightMapSrc = heightMapsrc;
this->_alphaMapSrc = alphamap;

View File

@ -135,15 +135,15 @@ public:
/**empty constructor*/
TerrainData();
/**constructor, this constructor construct a simple terrain which only have 1 detailmap*/
TerrainData(const std::string& heightMapsrc, const std::string& textureSrc, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
TerrainData(const std::string& heightMapsrc, const std::string& textureSrc, const Vec2 & chunksize = Vec2(32,32), float mapHeight = 2, float mapScale = 0.1);
/**constructor, this constructor construct a terrain which have 4 detailmaps, 1 alpha map*/
TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Vec2 & chunksize = Vec2(32,32), float mapHeight = 2, float mapScale = 0.1);
/**constructor, this constructor construct a terrain which have 3 detailmaps, 1 alpha map*/
TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const Vec2 & chunksize = Vec2(32,32), float mapHeight = 2, float mapScale = 0.1);
/**
*determine the chunk size,chunk is the minimal subdivision of the Terrain
*/
Size _chunkSize;
Vec2 _chunkSize;
/**height Map source path*/
std::string _heightMapSrc;
/**the source path of the alpha map*/
@ -263,7 +263,7 @@ private:
/**parent terrain*/
Terrain * _terrain;
/**chunk size*/
Size _size;
Vec2 _size;
/**chunk's estimated slope*/
float _slope;
std::vector<TerrainVertexData> _currentVertices;
@ -435,7 +435,7 @@ public:
/**
* get the terrain's size
*/
Size getTerrainSize() const { return Size(static_cast<float>(_imageWidth), static_cast<float>(_imageHeight)); }
Vec2 getTerrainSize() const { return Vec2(static_cast<float>(_imageWidth), static_cast<float>(_imageHeight)); }
/**
* get the terrain's height data
@ -508,7 +508,7 @@ protected:
std::vector<unsigned int> _indices;
int _imageWidth;
int _imageHeight;
Size _chunkSize;
Vec2 _chunkSize;
bool _isEnableFrustumCull;
int _maxDetailMapValue;
cocos2d::Image * _heightMapImage;

View File

@ -1269,14 +1269,14 @@ void Console::commandResolution(socket_native_type /*fd*/, const std::string& ar
void Console::commandResolutionSubCommandEmpty(socket_native_type fd, const std::string& /*args*/)
{
auto director = Director::getInstance();
Size points = director->getWinSize();
Size pixels = director->getWinSizeInPixels();
Vec2 points = director->getWinSize();
Vec2 pixels = director->getWinSizeInPixels();
auto glview = director->getOpenGLView();
Size design = glview->getDesignResolutionSize();
Vec2 design = glview->getDesignResolutionSize();
ResolutionPolicy res = glview->getResolutionPolicy();
Rect visibleRect = glview->getVisibleRect();
Console::Utility::mydprintf(fd, "Window Size:\n"
Console::Utility::mydprintf(fd, "Window Vec2:\n"
"\t%d x %d (points)\n"
"\t%d x %d (pixels)\n"
"\t%d x %d (design resolution)\n"

View File

@ -581,7 +581,7 @@ const Mat4& Director::getMatrix(MATRIX_STACK_TYPE type) const
void Director::setProjection(Projection projection)
{
Size size = _winSizeInPoints;
Vec2 size = _winSizeInPoints;
if (size.width == 0 || size.height == 0)
{
@ -684,7 +684,7 @@ Vec2 Director::convertToGL(const Vec2& uiPoint)
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
float zClip = transform.m[14]/transform.m[15];
Size glSize = _openGLView->getDesignResolutionSize();
Vec2 glSize = _openGLView->getDesignResolutionSize();
Vec4 clipCoord(2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip, 1);
Vec4 glCoord;
@ -716,22 +716,22 @@ Vec2 Director::convertToUI(const Vec2& glPoint)
clipCoord.y = clipCoord.y / clipCoord.w;
clipCoord.z = clipCoord.z / clipCoord.w;
Size glSize = _openGLView->getDesignResolutionSize();
Vec2 glSize = _openGLView->getDesignResolutionSize();
float factor = 1.0f / glCoord.w;
return Vec2(glSize.width * (clipCoord.x * 0.5f + 0.5f) * factor, glSize.height * (-clipCoord.y * 0.5f + 0.5f) * factor);
}
const Size& Director::getWinSize() const
const Vec2& Director::getWinSize() const
{
return _winSizeInPoints;
}
Size Director::getWinSizeInPixels() const
Vec2 Director::getWinSizeInPixels() const
{
return Size(_winSizeInPoints.width * _contentScaleFactor, _winSizeInPoints.height * _contentScaleFactor);
return Vec2(_winSizeInPoints.width * _contentScaleFactor, _winSizeInPoints.height * _contentScaleFactor);
}
Size Director::getVisibleSize() const
Vec2 Director::getVisibleSize() const
{
if (_openGLView)
{
@ -739,7 +739,7 @@ Size Director::getVisibleSize() const
}
else
{
return Size::ZERO;
return Vec2::ZERO;
}
}

View File

@ -230,16 +230,16 @@ public:
// window size
/** Returns the size of the OpenGL view in points. */
const Size& getWinSize() const;
const Vec2& getWinSize() const;
/** Returns the size of the OpenGL view in pixels. */
Size getWinSizeInPixels() const;
Vec2 getWinSizeInPixels() const;
/**
* Returns visible size of the OpenGL view in points.
* The value is equal to `Director::getWinSize()` if don't invoke `GLView::setDesignResolutionSize()`.
*/
Size getVisibleSize() const;
Vec2 getVisibleSize() const;
/** Returns visible origin coordinate of the OpenGL view in points. */
Vec2 getVisibleOrigin() const;
@ -620,7 +620,7 @@ protected:
Projection _projection = Projection::DEFAULT;
/* window size in points */
Size _winSizeInPoints = Size::ZERO;
Vec2 _winSizeInPoints = Vec2::ZERO;
/* content scale factor */
float _contentScaleFactor = 1.0f;

View File

@ -28,7 +28,7 @@
#define __cocos2d_libs__CCMouseEvent__
#include "base/CCEvent.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
/**
* @addtogroup base

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
#define __CC_IME_DELEGATE_H__
#include <string>
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "base/CCEventKeyboard.h"
/**

View File

@ -165,9 +165,9 @@ Vec2 PointFromString(const std::string& str)
return ret;
}
Size SizeFromString(const std::string& pszContent)
Vec2 SizeFromString(const std::string& pszContent)
{
Size ret = Size::ZERO;
Vec2 ret = Vec2::ZERO;
do
{
@ -177,7 +177,7 @@ Size SizeFromString(const std::string& pszContent)
float width = (float) utils::atof(strs[0].c_str());
float height = (float) utils::atof(strs[1].c_str());
ret = Size(width, height);
ret = Vec2(width, height);
} while (0);
return ret;

View File

@ -27,7 +27,7 @@ THE SOFTWARE.
#ifndef __PLATFORM_CCNS_H__
#define __PLATFORM_CCNS_H__
#include "math/CCGeometry.h"
#include "math/CCMath.h"
NS_CC_BEGIN
@ -68,9 +68,9 @@ Vec2 CC_DLL PointFromString(const std::string& str);
* An example of a valid string is "{3.0,2.5}".
* The string is not localized, so items are always separated with a comma.
* @return A Core Graphics structure that represents a size.
* If the string is not well-formed, the function returns Size::ZERO.
* If the string is not well-formed, the function returns Vec2::ZERO.
*/
Size CC_DLL SizeFromString(const std::string& str);
Vec2 CC_DLL SizeFromString(const std::string& str);
// end of data_structure group
/** @} */

View File

@ -23,7 +23,7 @@
THE SOFTWARE.
****************************************************************************/
#include "platform/CCPlatformMacros.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
NS_CC_BEGIN

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
#define __CC_TOUCH_H__
#include "base/CCRef.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
NS_CC_BEGIN

View File

@ -163,14 +163,14 @@ On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
Converts a rect in pixels to points
*/
#define CC_SIZE_PIXELS_TO_POINTS(__size_in_pixels__) \
cocos2d::Size((__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), \
Vec2((__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), \
(__size_in_pixels__).height / CC_CONTENT_SCALE_FACTOR())
/** @def CC_POINT_POINTS_TO_PIXELS
Converts a rect in points to pixels
*/
#define CC_SIZE_POINTS_TO_PIXELS(__size_in_points__) \
cocos2d::Size((__size_in_points__).width* CC_CONTENT_SCALE_FACTOR(), \
Vec2((__size_in_points__).width* CC_CONTENT_SCALE_FACTOR(), \
(__size_in_points__).height* CC_CONTENT_SCALE_FACTOR())
#ifndef FLT_EPSILON

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#include <string>
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "math/CCMath.h"
#include "base/CCRef.h"
#include "renderer/backend/Types.h"
@ -504,7 +504,7 @@ struct CC_DLL T2F_Quad
struct CC_DLL AnimationFrameData
{
T2F_Quad texCoords;
Size size;
Vec2 size;
float delay = 0.f;
};
@ -518,7 +518,7 @@ struct CC_DLL AnimationFrameData
struct CC_DLL FontShadow
{
/// shadow x and y offset
Size _shadowOffset;
Vec2 _shadowOffset;
/// shadow blurriness
float _shadowBlur = 0.f;
/// shadow opacity
@ -558,7 +558,7 @@ struct CC_DLL FontDefinition
/// vertical alignment
TextVAlignment _vertAlignment = TextVAlignment::TOP;
/// rendering box
Size _dimensions = Size::ZERO;
Vec2 _dimensions = Vec2::ZERO;
/// font color
Color3B _fontFillColor = Color3B::WHITE;
/// font alpha

View File

@ -236,7 +236,7 @@ long long getTimeInMilliseconds()
Rect getCascadeBoundingBox(Node *node)
{
Rect cbb;
Size contentSize = node->getContentSize();
Vec2 contentSize = node->getContentSize();
// check all children bounding box, get maximize box
Node* child = nullptr;

View File

@ -89,7 +89,7 @@ THE SOFTWARE.
// math
#include "math/CCAffineTransform.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "math/CCVertex.h"
#include "math/Mat4.h"
#include "math/MathUtil.h"

View File

@ -57,9 +57,9 @@ Vec2 PointApplyTransform(const Vec2& point, const Mat4& transform)
}
Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t)
Vec2 __CCSizeApplyAffineTransform(const Vec2& size, const AffineTransform& t)
{
Size s;
Vec2 s;
s.width = (float)((double)t.a * size.width + (double)t.c * size.height);
s.height = (float)((double)t.b * size.width + (double)t.d * size.height);
return s;

View File

@ -29,7 +29,6 @@ THE SOFTWARE.
#include "platform/CCPlatformMacros.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
/**
@ -68,7 +67,7 @@ CC_DLL Vec2 __CCPointApplyAffineTransform(const Vec2& point, const AffineTransfo
#define PointApplyAffineTransform __CCPointApplyAffineTransform
/**Multiply size (width,height,0) by a affine transform.*/
CC_DLL Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t);
CC_DLL Vec2 __CCSizeApplyAffineTransform(const Vec2& size, const AffineTransform& t);
#define SizeApplyAffineTransform __CCSizeApplyAffineTransform
/**Make identity affine transform.*/
CC_DLL AffineTransform AffineTransformMakeIdentity();

View File

@ -29,6 +29,7 @@
#include "math/Vec3.h"
#include "math/Vec4.h"
#include "math/Mat4.h"
#include "math/Rect.h"
#include "math/Quaternion.h"
#endif

View File

@ -6,17 +6,16 @@ set(COCOS_MATH_HEADER
math/TransformUtils.h
math/Vec4.h
math/CCAffineTransform.h
math/CCGeometry.h
math/CCVertex.h
math/Vec3.h
math/CCMathBase.h
math/MathUtil.h
math/CCMath.h
math/Rect.h
)
set(COCOS_MATH_SRC
math/CCAffineTransform.cpp
math/CCGeometry.cpp
math/CCVertex.cpp
math/Mat3.cpp
math/Mat4.cpp
@ -26,4 +25,5 @@ set(COCOS_MATH_SRC
math/Vec2.cpp
math/Vec3.cpp
math/Vec4.cpp
math/Rect.cpp
)

View File

@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "math/CCGeometry.h"
#include "math/Rect.h"
#include <algorithm>
#include <cmath>
@ -33,71 +33,6 @@ THE SOFTWARE.
// implementation of Vec2
NS_CC_BEGIN
// implementation of Size
Size::Size() : width(0), height(0)
{
}
Size::Size(float w, float h) : width(w), height(h)
{
}
Size::Size(const Size& other) : width(other.width), height(other.height)
{
}
Size::Size(const Vec2& point) : width(point.x), height(point.y)
{
}
Size& Size::operator= (const Size& other)
{
setSize(other.width, other.height);
return *this;
}
Size& Size::operator= (const Vec2& point)
{
setSize(point.x, point.y);
return *this;
}
Size Size::operator+(const Size& right) const
{
return Size(this->width + right.width, this->height + right.height);
}
Size Size::operator-(const Size& right) const
{
return Size(this->width - right.width, this->height - right.height);
}
Size Size::operator*(float a) const
{
return Size(this->width * a, this->height * a);
}
Size Size::operator/(float a) const
{
CCASSERT(a!=0, "CCSize division by 0.");
return Size(this->width / a, this->height / a);
}
void Size::setSize(float w, float h)
{
this->width = w;
this->height = h;
}
bool Size::equals(const Size& target) const
{
return (std::abs(this->width - target.width) < FLT_EPSILON)
&& (std::abs(this->height - target.height) < FLT_EPSILON);
}
const Size Size::ZERO = Size(0, 0);
// implementation of Rect
Rect::Rect()
@ -109,19 +44,19 @@ Rect::Rect(float x, float y, float width, float height)
{
setRect(x, y, width, height);
}
Rect::Rect(const Vec2& pos, const Size& dimension)
Rect::Rect(const Vec2& pos, const Vec2& dimension)
{
setRect(pos.x, pos.y, dimension.width, dimension.height);
setRect(pos.x, pos.y, dimension.x, dimension.y);
}
Rect::Rect(const Rect& other)
{
setRect(other.origin.x, other.origin.y, other.size.width, other.size.height);
setRect(other.origin.x, other.origin.y, other.size.x, other.size.y);
}
Rect& Rect::operator= (const Rect& other)
{
setRect(other.origin.x, other.origin.y, other.size.width, other.size.height);
setRect(other.origin.x, other.origin.y, other.size.x, other.size.y);
return *this;
}
@ -133,8 +68,8 @@ void Rect::setRect(float x, float y, float width, float height)
origin.x = x;
origin.y = y;
size.width = width;
size.height = height;
size.x = width;
size.y = height;
}
bool Rect::equals(const Rect& rect) const
@ -145,12 +80,12 @@ bool Rect::equals(const Rect& rect) const
float Rect::getMaxX() const
{
return origin.x + size.width;
return origin.x + size.x;
}
float Rect::getMidX() const
{
return origin.x + size.width / 2.0f;
return origin.x + size.x / 2.0f;
}
float Rect::getMinX() const
@ -160,12 +95,12 @@ float Rect::getMinX() const
float Rect::getMaxY() const
{
return origin.y + size.height;
return origin.y + size.y;
}
float Rect::getMidY() const
{
return origin.y + size.height / 2.0f;
return origin.y + size.y / 2.0f;
}
float Rect::getMinY() const
@ -196,11 +131,11 @@ bool Rect::intersectsRect(const Rect& rect) const
bool Rect::intersectsCircle(const Vec2& center, float radius) const
{
Vec2 rectangleCenter((origin.x + size.width / 2),
(origin.y + size.height / 2));
Vec2 rectangleCenter((origin.x + size.x / 2),
(origin.y + size.y / 2));
float w = size.width / 2;
float h = size.height / 2;
float w = size.x / 2;
float h = size.y / 2;
float dx = std::abs(center.x - rectangleCenter.x);
float dy = std::abs(center.y - rectangleCenter.y);
@ -240,8 +175,8 @@ void Rect::merge(const Rect& rect)
Rect Rect::unionWithRect(const Rect & rect) const
{
float thisLeftX = origin.x;
float thisRightX = origin.x + size.width;
float thisTopY = origin.y + size.height;
float thisRightX = origin.x + size.x;
float thisTopY = origin.y + size.y;
float thisBottomY = origin.y;
if (thisRightX < thisLeftX)
@ -255,8 +190,8 @@ Rect Rect::unionWithRect(const Rect & rect) const
}
float otherLeftX = rect.origin.x;
float otherRightX = rect.origin.x + rect.size.width;
float otherTopY = rect.origin.y + rect.size.height;
float otherRightX = rect.origin.x + rect.size.x;
float otherTopY = rect.origin.y + rect.size.y;
float otherBottomY = rect.origin.y;
if (otherRightX < otherLeftX)

View File

@ -24,12 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __MATH_CCGEOMETRY_H__
#define __MATH_CCGEOMETRY_H__
#ifndef __MATH_RECT_H__
#define __MATH_RECT_H__
#include "platform/CCPlatformMacros.h"
#include "base/ccMacros.h"
#include "math/CCMath.h"
#include "math/Vec2.h"
/**
* @addtogroup base
@ -38,80 +36,6 @@ THE SOFTWARE.
NS_CC_BEGIN
class CC_DLL Size
{
public:
/**Width of the Size.*/
float width;
/**Height of the Size.*/
float height;
public:
/**Conversion from Vec2 to Size.*/
operator Vec2() const
{
return Vec2(width, height);
}
public:
/**
@{
Constructor.
@param width Width of the size.
@param height Height of the size.
@param other Copy constructor.
@param point Conversion from a point.
*/
Size();
Size(float width, float height);
Size(const Size& other);
explicit Size(const Vec2& point);
/**@}*/
/**
* @js NA
* @lua NA
*/
Size& operator= (const Size& other);
/**
* @js NA
* @lua NA
*/
Size& operator= (const Vec2& point);
/**
* @js NA
* @lua NA
*/
Size operator+(const Size& right) const;
/**
* @js NA
* @lua NA
*/
Size operator-(const Size& right) const;
/**
* @js NA
* @lua NA
*/
Size operator*(float a) const;
/**
* @js NA
* @lua NA
*/
Size operator/(float a) const;
/**
Set the width and height of Size.
* @js NA
* @lua NA
*/
void setSize(float width, float height);
/**
Check if two size is the same.
* @js NA
*/
bool equals(const Size& target) const;
/**Size(0,0).*/
static const Size ZERO;
};
/**Rectangle area.*/
class CC_DLL Rect
{
@ -119,7 +43,7 @@ public:
/**Low left point of rect.*/
Vec2 origin;
/**Width and height of the rect.*/
Size size;
Vec2 size;
public:
/**
@ -136,7 +60,7 @@ public:
Constructor a rect.
* @js NA
*/
Rect(const Vec2& pos, const Size& dimension);
Rect(const Vec2& pos, const Vec2& dimension);
/**
Copy constructor.
* @js NA

View File

@ -55,16 +55,27 @@ class CC_DLL Vec2
{
public:
/**
* The x coordinate.
*/
float x = 0.f;
union
{
struct
{
/**
* The y coordinate.
*/
float y = 0.f;
/**
* The x coordinate.
*/
float x;
/**
* The y coordinate.
*/
float y;
};
struct {
float width;
float height;
};
};
/**
* Constructs a new vector initialized to all zeros.
*/
@ -273,6 +284,11 @@ public:
*/
inline void set(float xx, float yy);
/**
* [DEPRECATED] use Vec2::set instead
*/
inline void setSize(float w, float h) { this->set(w, h); }
/**
* Sets the elements of this vector from the values in the specified array.
*
@ -748,6 +764,9 @@ inline Vec2 operator*(float x, const Vec2& v);
typedef Vec2 Point;
// [DEPRECATED] compatible only
typedef Vec2 Size;
NS_CC_MATH_END
/**

View File

@ -189,7 +189,7 @@ PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& mate
return nullptr;
}
PhysicsBody* PhysicsBody::createBox(const Size& size, const PhysicsMaterial& material, const Vec2& offset)
PhysicsBody* PhysicsBody::createBox(const Vec2& size, const PhysicsMaterial& material, const Vec2& offset)
{
PhysicsBody* body = new (std::nothrow) PhysicsBody();
if (body && body->init())
@ -232,7 +232,7 @@ PhysicsBody* PhysicsBody::createEdgeSegment(const Vec2& a, const Vec2& b, const
return nullptr;
}
PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& material, float border/* = 1*/, const Vec2& offset)
PhysicsBody* PhysicsBody::createEdgeBox(const Vec2& size, const PhysicsMaterial& material, float border/* = 1*/, const Vec2& offset)
{
PhysicsBody* body = new (std::nothrow) PhysicsBody();
if (body && body->init())

View File

@ -30,7 +30,7 @@
#if CC_USE_PHYSICS
#include "2d/CCComponent.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "physics/CCPhysicsShape.h"
#include "base/CCVector.h"
@ -104,12 +104,12 @@ public:
/**
* Create a body contains a box shape.
*
* @param size Size contains this box's width and height.
* @param size Vec2 contains this box's width and height.
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
* @return An autoreleased PhysicsBody object pointer.
*/
static PhysicsBody* createBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO);
static PhysicsBody* createBox(const Vec2& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO);
/**
* @brief Create a body contains a polygon shape.
@ -135,13 +135,13 @@ public:
/**
* Create a body contains a EdgeBox shape.
* @param size Size contains this box's width and height.
* @param size Vec2 contains this box's width and height.
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
* @param border It's a edge's border width.
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
* @return An autoreleased PhysicsBody object pointer.
*/
static PhysicsBody* createEdgeBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1, const Vec2& offset = Vec2::ZERO);
static PhysicsBody* createEdgeBox(const Vec2& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1, const Vec2& offset = Vec2::ZERO);
/**
* Create a body contains a EdgePolygon shape.

View File

@ -30,7 +30,7 @@
#if CC_USE_PHYSICS
#include "base/CCRef.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "base/CCEventListenerCustom.h"
#include "base/CCEvent.h"
#include "base/CCEventCustom.h"

View File

@ -31,7 +31,7 @@
#include "chipmunk/chipmunk.h"
#include "platform/CCPlatformMacros.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
NS_CC_BEGIN
@ -45,7 +45,7 @@ NS_CC_BEGIN
/**
* A physics helper class.
*
* Support for conversion between the chipmunk types and cocos types, eg: cpVect to Vec2, cpVect to Size, cpFloat to float.
* Support for conversion between the chipmunk types and cocos types, eg: cpVect to Vec2, cpVect to Vec2, cpFloat to float.
*/
class PhysicsHelper
{
@ -56,11 +56,11 @@ public:
/** Make Vec2 type convert to cpVect type. */
static cpVect point2cpv(const Vec2& point) { return cpv(point.x, point.y); }
/** Make cpVect type convert to Size type. */
static Size cpv2size(const cpVect& vec) { return Size(vec.x, vec.y); }
/** Make cpVect type convert to Vec2 type. */
static Vec2 cpv2size(const cpVect& vec) { return Vec2(vec.x, vec.y); }
/** Make Size type convert to cpVect type. */
static cpVect size2cpv(const Size& size) { return cpv(size.width, size.height); }
/** Make Vec2 type convert to cpVect type. */
static cpVect size2cpv(const Vec2& size) { return cpv(size.width, size.height); }
/** Make cpFloat type convert to float type. */
static float cpfloat2float(cpFloat f) { return f; }

View File

@ -32,7 +32,7 @@
#if CC_USE_PHYSICS
#include "base/CCRef.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
struct cpConstraint;

View File

@ -482,7 +482,7 @@ void PhysicsShapeEdgeSegment::updateScale()
}
// PhysicsShapeBox
PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset/* = Vec2(0, 0)*/, float radius/* = 0.0f*/)
PhysicsShapeBox* PhysicsShapeBox::create(const Vec2& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset/* = Vec2(0, 0)*/, float radius/* = 0.0f*/)
{
PhysicsShapeBox* shape = new (std::nothrow) PhysicsShapeBox();
if (shape && shape->init(size, material, offset, radius))
@ -495,7 +495,7 @@ PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial
return nullptr;
}
bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset /*= Vec2(0, 0)*/, float radius/* = 0.0f*/)
bool PhysicsShapeBox::init(const Vec2& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Vec2& offset /*= Vec2(0, 0)*/, float radius/* = 0.0f*/)
{
do
{
@ -527,7 +527,7 @@ bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* =
return false;
}
Size PhysicsShapeBox::getSize() const
Vec2 PhysicsShapeBox::getSize() const
{
cpShape* shape = _cpShapes.front();
return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)),
@ -699,7 +699,7 @@ void PhysicsShapePolygon::updateScale()
}
// PhysicsShapeEdgeBox
PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vec2& offset/* = Vec2(0, 0)*/)
PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Vec2& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vec2& offset/* = Vec2(0, 0)*/)
{
PhysicsShapeEdgeBox* shape = new (std::nothrow) PhysicsShapeEdgeBox();
if (shape && shape->init(size, material, border, offset))
@ -712,7 +712,7 @@ PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const Physics
return nullptr;
}
bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vec2& offset/*= Vec2(0, 0)*/)
bool PhysicsShapeEdgeBox::init(const Vec2& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Vec2& offset/*= Vec2(0, 0)*/)
{
do
{

View File

@ -30,7 +30,7 @@
#if CC_USE_PHYSICS
#include "base/CCRef.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
struct cpShape;
@ -526,19 +526,19 @@ public:
/**
* Creates a PhysicsShapeBox with specified value.
*
* @param size Size contains this box's width and height.
* @param size Vec2 contains this box's width and height.
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
* @return An autoreleased PhysicsShapeBox object pointer.
*/
static PhysicsShapeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO, float radius = 0.0f);
static PhysicsShapeBox* create(const Vec2& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO, float radius = 0.0f);
/**
* Get this box's width and height.
*
* @return An Size object.
* @return An Vec2 object.
*/
Size getSize() const;
Vec2 getSize() const;
/**
* Get this box's position offset.
@ -548,7 +548,7 @@ public:
virtual Vec2 getOffset() override { return getCenter(); }
protected:
bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO, float radius = 0.0f);
bool init(const Vec2& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO, float radius = 0.0f);
protected:
PhysicsShapeBox();
@ -656,13 +656,13 @@ public:
/**
* Creates a PhysicsShapeEdgeBox with specified value.
*
* @param size Size contains this box's width and height.
* @param size Vec2 contains this box's width and height.
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
* @param border It's a edge's border width.
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
* @return An autoreleased PhysicsShapeEdgeBox object pointer.
*/
static PhysicsShapeEdgeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Vec2& offset = Vec2::ZERO);
static PhysicsShapeEdgeBox* create(const Vec2& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Vec2& offset = Vec2::ZERO);
/**
* Get this box's position offset.
@ -672,7 +672,7 @@ public:
virtual Vec2 getOffset() override { return getCenter(); }
protected:
bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Vec2& offset = Vec2::ZERO);
bool init(const Vec2& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Vec2& offset = Vec2::ZERO);
protected:
PhysicsShapeEdgeBox();

View File

@ -31,7 +31,7 @@
#include <list>
#include "base/CCVector.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "physics/CCPhysicsBody.h"
struct cpSpace;
@ -64,7 +64,7 @@ typedef struct PhysicsRayCastInfo
// FIXME: correct thing to do is use `cpFloat` instead of float.
// but in order to do so, we should include "chipmunk_types.h"
// in Chipmunk v7.0, chipmunk_types includes all the mac types that
// conflicts with cocos2d Size, Point,... etc types. And all the CocosStudio
// conflicts with cocos2d Vec2, Point,... etc types. And all the CocosStudio
// lib will need to use the `cocos2d::` namespace prefix. And it is easier to do this
// than change all the cocosstudio library (and also users code)
float fraction;

View File

@ -179,29 +179,29 @@ void GLView::setDesignResolutionSize(float width, float height, ResolutionPolicy
return;
}
_designResolutionSize.setSize(width, height);
_designResolutionSize.set(width, height);
_resolutionPolicy = resolutionPolicy;
updateDesignResolutionSize();
}
const Size& GLView::getDesignResolutionSize() const
const Vec2& GLView::getDesignResolutionSize() const
{
return _designResolutionSize;
}
Size GLView::getFrameSize() const
Vec2 GLView::getFrameSize() const
{
return _screenSize;
}
void GLView::setFrameSize(float width, float height)
{
_screenSize = Size(width, height);
_screenSize = Vec2(width, height);
// Github issue #16003 and #16485
// only update the designResolution if it wasn't previously set
if (_designResolutionSize.equals(Size::ZERO))
if (_designResolutionSize.equals(Vec2::ZERO))
_designResolutionSize = _screenSize;
}
@ -218,11 +218,11 @@ Rect GLView::getSafeAreaRect() const
return getVisibleRect();
}
Size GLView::getVisibleSize() const
Vec2 GLView::getVisibleSize() const
{
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
{
return Size(_screenSize.width/_scaleX, _screenSize.height/_scaleY);
return Vec2(_screenSize.width/_scaleX, _screenSize.height/_scaleY);
}
else
{

View File

@ -170,7 +170,7 @@ public:
*
* @return The frame size of EGL view.
*/
virtual Size getFrameSize() const;
virtual Vec2 getFrameSize() const;
/**
* Set the frame size of EGL view.
@ -228,7 +228,7 @@ public:
*
* @return The visible area size of opengl viewport.
*/
virtual Size getVisibleSize() const;
virtual Vec2 getVisibleSize() const;
/**
* Get the visible origin point of opengl viewport.
@ -265,7 +265,7 @@ public:
*
* @return The design resolution size.
*/
virtual const Size& getDesignResolutionSize() const;
virtual const Vec2& getDesignResolutionSize() const;
/**
* Set opengl view port rectangle with points.
@ -434,9 +434,9 @@ protected:
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, intptr_t ids[], float xs[], float ys[]);
// real screen size
Size _screenSize;
Vec2 _screenSize;
// resolution size, it is the size appropriate for the app resources.
Size _designResolutionSize;
Vec2 _designResolutionSize;
// the view port size
Rect _viewPortRect;
// the view name

View File

@ -753,7 +753,7 @@ int GLViewImpl::getMonitorCount() const {
return count;
}
Size GLViewImpl::getMonitorSize() const {
Vec2 GLViewImpl::getMonitorSize() const {
GLFWmonitor* monitor = _monitor;
if (nullptr == monitor) {
GLFWwindow* window = this->getWindow();
@ -764,10 +764,10 @@ Size GLViewImpl::getMonitorSize() const {
}
if (nullptr != monitor) {
const GLFWvidmode* videoMode = glfwGetVideoMode(monitor);
Size size = Size((float)videoMode->width, (float)videoMode->height);
Vec2 size = Vec2((float)videoMode->width, (float)videoMode->height);
return size;
}
return Size::ZERO;
return Vec2::ZERO;
}
void GLViewImpl::updateFrameSize()

View File

@ -105,7 +105,7 @@ public:
void setWindowed(int width, int height);
int getMonitorCount() const;
Size getMonitorSize() const;
Vec2 getMonitorSize() const;
/* override functions */
virtual bool isOpenGLReady() override;

View File

@ -754,7 +754,7 @@ void Renderer::flushTriangles()
}
// helpers
bool Renderer::checkVisibility(const Mat4 &transform, const Size &size)
bool Renderer::checkVisibility(const Mat4 &transform, const Vec2 &size)
{
auto director = Director::getInstance();
auto scene = director->getRunningScene();

View File

@ -401,7 +401,7 @@ public:
const ScissorRect& getScissorRect() const; ///< Get scissor rectangle.
/** returns whether or not a rectangle is visible or not */
bool checkVisibility(const Mat4& transform, const Size& size);
bool checkVisibility(const Mat4& transform, const Vec2& size);
/** read pixels from RenderTarget or screen framebuffer */
void readPixels(backend::RenderTarget* rt, std::function<void(const backend::PixelBufferDescriptor&)> callback);

View File

@ -114,16 +114,16 @@ backend::TextureBackend* Texture2D::getBackendTexture() const
return _texture;
}
Size Texture2D::getContentSize() const
Vec2 Texture2D::getContentSize() const
{
Size ret;
Vec2 ret;
ret.width = _contentSize.width / CC_CONTENT_SCALE_FACTOR();
ret.height = _contentSize.height / CC_CONTENT_SCALE_FACTOR();
return ret;
}
const Size& Texture2D::getContentSizeInPixels()
const Vec2& Texture2D::getContentSizeInPixels()
{
return _contentSize;
}
@ -159,7 +159,7 @@ void Texture2D::setPremultipliedAlpha(bool premultipliedAlpha)
else _flags &= ~TextureFlag::PREMULTIPLIEDALPHA;
}
bool Texture2D::initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& /*contentSize*/, bool preMultipliedAlpha)
bool Texture2D::initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Vec2& /*contentSize*/, bool preMultipliedAlpha)
{
CCASSERT(dataLen>0 && pixelsWide>0 && pixelsHigh>0, "Invalid size");
@ -201,7 +201,7 @@ bool Texture2D::updateWithImage(Image* image, backend::PixelFormat format, int i
}
unsigned char* tempData = image->getData();
Size imageSize = Size((float)imageWidth, (float)imageHeight);
Vec2 imageSize = Vec2((float)imageWidth, (float)imageHeight);
backend::PixelFormat renderFormat = (PixelFormat::NONE == format) ? image->getPixelFormat() : format;
backend::PixelFormat imagePixelFormat = image->getPixelFormat();
size_t tempDataLen = image->getDataLen();
@ -257,7 +257,7 @@ bool Texture2D::updateWithImage(Image* image, backend::PixelFormat format, int i
return true;
}
bool Texture2D::updateWithData(const void* data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& /*contentSize*/, bool preMultipliedAlpha, int index)
bool Texture2D::updateWithData(const void* data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Vec2& /*contentSize*/, bool preMultipliedAlpha, int index)
{
CCASSERT(dataLen > 0 && pixelsWide > 0 && pixelsHigh > 0, "Invalid size");
@ -377,7 +377,7 @@ bool Texture2D::updateWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::
}
if (index == 0) {
_contentSize = Size((float)pixelsWide, (float)pixelsHigh);
_contentSize = Vec2((float)pixelsWide, (float)pixelsHigh);
_pixelsWide = pixelsWide;
_pixelsHigh = pixelsHigh;
_pixelFormat = pixelFormat;
@ -421,7 +421,7 @@ bool Texture2D::initWithImage(Image *image, backend::PixelFormat format)
}
// implementation Texture2D (Text)
bool Texture2D::initWithString(const char *text, const std::string& fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, TextHAlignment hAlignment/* = TextHAlignment::CENTER */, TextVAlignment vAlignment/* = TextVAlignment::TOP */, bool enableWrap /* = false */, int overflow /* = 0 */)
bool Texture2D::initWithString(const char *text, const std::string& fontName, float fontSize, const Vec2& dimensions/* = Vec2(0, 0)*/, TextHAlignment hAlignment/* = TextHAlignment::CENTER */, TextVAlignment vAlignment/* = TextVAlignment::TOP */, bool enableWrap /* = false */, int overflow /* = 0 */)
{
FontDefinition tempDef;
@ -500,7 +500,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
return false;
}
Size imageSize = Size((float)imageWidth, (float)imageHeight);
Vec2 imageSize = Vec2((float)imageWidth, (float)imageHeight);
pixelFormat = backend::PixelFormatUtils::convertDataToFormat(outData.getBytes(), imageWidth*imageHeight*4, PixelFormat::RGBA8, pixelFormat, &outTempData, &outTempDataLen);
ret = initWithData(outTempData, outTempDataLen, pixelFormat, imageWidth, imageHeight, imageSize);

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
#include <unordered_map>
#include "base/CCRef.h"
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "base/ccTypes.h"
#include "renderer/CCCustomCommand.h"
@ -140,7 +140,7 @@ public:
* @js NA
* @lua NA
*/
bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize, bool preMultipliedAlpha = false) { return initWithData(data, dataLen, pixelFormat, pixelFormat, pixelsWide, pixelsHigh, contentSize, preMultipliedAlpha);}
bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Vec2& contentSize, bool preMultipliedAlpha = false) { return initWithData(data, dataLen, pixelFormat, pixelFormat, pixelsWide, pixelsHigh, contentSize, preMultipliedAlpha);}
/** Initializes with a texture2d with data.
@ -155,7 +155,7 @@ public:
* @js NA
* @lua NA
*/
bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& contentSize, bool preMultipliedAlpha = false);
bool initWithData(const void *data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Vec2& contentSize, bool preMultipliedAlpha = false);
/** Initializes with mipmaps.
@ -177,7 +177,7 @@ public:
@param height Specifies the height of the texture subimage.
*/
bool updateWithImage(Image* image, backend::PixelFormat format, int index = 0);
bool updateWithData(const void* data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Size& /*contentSize*/, bool preMultipliedAlpha, int index = 0);
bool updateWithData(const void* data, ssize_t dataLen, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, const Vec2& /*contentSize*/, bool preMultipliedAlpha, int index = 0);
bool updateWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::PixelFormat pixelFormat, backend::PixelFormat renderFormat, int pixelsWide, int pixelsHigh, bool preMultipliedAlpha = false, int index = 0);
/** Update with texture data.
@ -231,7 +231,7 @@ public:
@param enableWrap Whether enable text wrap or not.
@param overflow Whether shrink font size when content larger than the dimensions.
*/
bool initWithString(const char *text, const std::string &fontName, float fontSize, const Size& dimensions = Size(0, 0), TextHAlignment hAlignment = TextHAlignment::CENTER, TextVAlignment vAlignment = TextVAlignment::TOP, bool enableWrap = true, int overflow = 0);
bool initWithString(const char *text, const std::string &fontName, float fontSize, const Vec2& dimensions = Vec2(0, 0), TextHAlignment hAlignment = TextHAlignment::CENTER, TextVAlignment vAlignment = TextVAlignment::TOP, bool enableWrap = true, int overflow = 0);
/** Initializes a texture from a string using a text definition.
@ -290,7 +290,7 @@ public:
unsigned int getBitsPerPixelForFormat(backend::PixelFormat format) const;
/** Get content size. */
const Size& getContentSizeInPixels();
const Vec2& getContentSizeInPixels();
/** Whether or not the texture has their Alpha premultiplied. */
bool hasPremultipliedAlpha() const;
@ -325,7 +325,7 @@ public:
void setMaxT(float maxT);
/** Get the texture content size.*/
Size getContentSize() const;
Vec2 getContentSize() const;
std::string getPath()const { return _filePath; }
@ -396,7 +396,7 @@ protected:
float _maxT;
/** content size */
Size _contentSize;
Vec2 _contentSize;
uint16_t _flags : 16;
uint16_t _samplerFlags : 16;

View File

@ -768,7 +768,7 @@ VolatileTexture* VolatileTextureMgr::findVolotileTexture(Texture2D *tt)
return vt;
}
void VolatileTextureMgr::addDataTexture(Texture2D *tt, void* data, int dataLen, backend::PixelFormat pixelFormat, const Size& contentSize)
void VolatileTextureMgr::addDataTexture(Texture2D *tt, void* data, int dataLen, backend::PixelFormat pixelFormat, const Vec2& contentSize)
{
if (_isReloading)
{

View File

@ -256,7 +256,7 @@ protected:
void *_textureData;
int _dataLen;
Size _textureSize;
Vec2 _textureSize;
backend::PixelFormat _pixelFormat;
std::string _fileName;
@ -270,7 +270,7 @@ class CC_DLL VolatileTextureMgr
public:
static void addImageTexture(Texture2D *tt, const std::string& imageFileName);
static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition);
static void addDataTexture(Texture2D *tt, void* data, int dataLen, backend::PixelFormat pixelFormat, const Size& contentSize);
static void addDataTexture(Texture2D *tt, void* data, int dataLen, backend::PixelFormat pixelFormat, const Vec2& contentSize);
static void addImage(Texture2D *tt, Image *image);
static void removeTexture(Texture2D *t);
static void reloadAllTextures();

View File

@ -5,18 +5,18 @@
USING_NS_CC;
Size LayoutHelper::s_designSize;
Vec2 LayoutHelper::s_designSize;
float LayoutHelper::s_adjustedScale = 1.0f;
void LayoutHelper::setDesignSizeFixedEdge(const Size& designSize)
void LayoutHelper::setDesignSizeFixedEdge(const Vec2& designSize)
{
LayoutHelper::s_designSize = designSize;
// Set the design resolution//分辨率的大小
GLView* pEGLView = Director::getInstance()->getOpenGLView();
const Size& frameSize = pEGLView->getFrameSize();
const Vec2& frameSize = pEGLView->getFrameSize();
// Size lsSize = lsaSize;
// Vec2 lsSize = lsaSize;
float scaleX = (float)frameSize.width / designSize.width;
float scaleY = (float)frameSize.height / designSize.height;
@ -32,16 +32,16 @@ void LayoutHelper::setDesignSizeFixedEdge(const Size& designSize)
}
}
void LayoutHelper::setDesignSizeNoBorder(const cocos2d::Size& designSize)
void LayoutHelper::setDesignSizeNoBorder(const Vec2& designSize)
{
// save smart size
LayoutHelper::s_designSize = designSize;
// Set the design resolution//分辨率的大小
GLView* pEGLView = Director::getInstance()->getOpenGLView();
const cocos2d::Size& frameSize = pEGLView->getFrameSize();
const Vec2& frameSize = pEGLView->getFrameSize();
// Size lsSize = lsaSize;
// Vec2 lsSize = lsaSize;
float scaleX = (float)frameSize.width / LayoutHelper::s_designSize.width;
float scaleY = (float)frameSize.height / LayoutHelper::s_designSize.height;
@ -67,17 +67,17 @@ cocos2d::Vec2 LayoutHelper::getVisibleOrigin(void)
(adjustedDesignSize.height - LayoutHelper::s_designSize.height) * .5f);
}
cocos2d::Size LayoutHelper::getVisibleSize(void)
Vec2 LayoutHelper::getVisibleSize(void)
{
return LayoutHelper::s_designSize;
}
/// Get node group size
Size LayoutHelper::getNodeGroupSize(const std::vector<Node*>& nodes)
Vec2 LayoutHelper::getNodeGroupSize(const std::vector<Node*>& nodes)
{
if (nodes.empty())
{
return Size::ZERO;
return Vec2::ZERO;
}
// group nodes locators
@ -109,13 +109,13 @@ Size LayoutHelper::getNodeGroupSize(const std::vector<Node*>& nodes)
float groupWidth = maxX - minX;
float groupHeight = maxY - minY;
return Size(groupWidth, groupHeight);
return Vec2(groupWidth, groupHeight);
}
/// Set nodes group size
void LayoutHelper::setNodeGroupSize(const std::vector<Node*>& nodes, const cocos2d::Size& newSize)
void LayoutHelper::setNodeGroupSize(const std::vector<Node*>& nodes, const Vec2& newSize)
{
cocos2d::Size groupSize = getNodeGroupScaledSize(nodes);
Vec2 groupSize = getNodeGroupScaledSize(nodes);
if (groupSize.height == 0 || groupSize.width == 0 || newSize.width == 0 || newSize.height == 0)
{
return;
@ -137,18 +137,18 @@ void LayoutHelper::setNodeGroupSize(const std::vector<Node*>& nodes, const coc
}
else {
(*iter)->setContentSize(
Size(
Vec2(
(*iter)->getContentSize().width * scaleX,
(*iter)->getContentSize().height * scaleY));
}
}
}
Size LayoutHelper::getNodeGroupScaledSize(const std::vector<Node*>& nodes)
Vec2 LayoutHelper::getNodeGroupScaledSize(const std::vector<Node*>& nodes)
{
if (nodes.empty())
{
return Size::ZERO;
return Vec2::ZERO;
}
auto scale = getScale2D(nodes[0]);
@ -185,7 +185,7 @@ Size LayoutHelper::getNodeGroupScaledSize(const std::vector<Node*>& nodes)
float groupWidth = maxX - minX;
float groupHeight = maxY - minY;
return cocos2d::Size(groupWidth, groupHeight);
return Vec2(groupWidth, groupHeight);
}
/// Get Node group left
@ -695,7 +695,7 @@ void LayoutHelper::makeSameWidth(const std::vector<Node*>& nodes)
}
#if (defined(_WIN32) && _MSC_VER >= 1700) || !defined(_WIN32)
std::for_each(nodes.begin(), nodes.end(), [maxWidth](Node* child)->void{
child->setContentSize(Size(maxWidth, child->getContentSize().height));
child->setContentSize(Vec2(maxWidth, child->getContentSize().height));
});
#else
#endif
@ -721,7 +721,7 @@ void LayoutHelper::makeSameHeight(const std::vector<Node*>& nodes)
}
#if (defined(_WIN32) && _MSC_VER >= 1700) || !defined(_WIN32)
std::for_each(nodes.begin(), nodes.end(), [minHeight](Node* child)->void{
child->setContentSize(Size(child->getContentSize().width, minHeight));
child->setContentSize(Vec2(child->getContentSize().width, minHeight));
});
#else
#endif
@ -926,7 +926,7 @@ cocos2d::Rect LayoutHelper::VisibleRect::getScreenVisibleRect()
return cocos2d::Rect(s_ScreenVisibleRect.origin.x, s_ScreenVisibleRect.origin.y, s_ScreenVisibleRect.size.width, s_ScreenVisibleRect.size.height);
}
cocos2d::Size LayoutHelper::VisibleRect::size()
Vec2 LayoutHelper::VisibleRect::size()
{
lazyInit();
return s_ScreenVisibleRect.size;
@ -1020,9 +1020,9 @@ float LayoutHelper::VisibleRect::getNodeTop(Node* pNode)
void LayoutHelper::VisibleRect::setNodeLeft(Node* pNode, float left)
{
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(0, scrSize.height) - LayoutHelper::VisibleRect::leftTop();
Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1036,9 +1036,9 @@ void LayoutHelper::VisibleRect::setNodeLeft(Node* pNode, float left)
void LayoutHelper::VisibleRect::setNodeTop(Node* pNode, float top)
{
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(0, scrSize.height) - LayoutHelper::VisibleRect::leftTop();
Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1053,9 +1053,9 @@ void LayoutHelper::VisibleRect::setNodeTop(Node* pNode, float top)
void LayoutHelper::VisibleRect::setNodeRight(Node* pNode, float right)
{
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(scrSize.width, 0) - LayoutHelper::VisibleRect::rightBottom();
Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1069,9 +1069,9 @@ void LayoutHelper::VisibleRect::setNodeRight(Node* pNode, float right)
void LayoutHelper::VisibleRect::setNodeBottom(Node* pNode, float bottom)
{
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(scrSize.width, 0) - LayoutHelper::VisibleRect::rightBottom();
Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1087,9 +1087,9 @@ void LayoutHelper::VisibleRect::setNodeBottom(Node* pNode, float bottom)
void LayoutHelper::VisibleRect::setNodeLT(Node* pNode, const cocos2d::Point& p)
{
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(0, scrSize.height) - LayoutHelper::VisibleRect::leftTop();
Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1104,9 +1104,9 @@ void LayoutHelper::VisibleRect::setNodeLT(Node* pNode, const cocos2d::Point& p)
void LayoutHelper::VisibleRect::setNodeRT(Node* pNode, const cocos2d::Point& p)
{ // right top
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(scrSize.width, scrSize.height) - LayoutHelper::VisibleRect::rightTop();
Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1120,9 +1120,9 @@ void LayoutHelper::VisibleRect::setNodeRT(Node* pNode, const cocos2d::Point& p)
void LayoutHelper::VisibleRect::setNodeLB(Node* pNode, const cocos2d::Point& p)
{ // left bottom
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(0, 0) - LayoutHelper::VisibleRect::leftBottom();
Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1136,9 +1136,9 @@ void LayoutHelper::VisibleRect::setNodeLB(Node* pNode, const cocos2d::Point& p)
void LayoutHelper::VisibleRect::setNodeRB(Node* pNode, const cocos2d::Point& p)
{ // right bottom
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(scrSize.width, 0) - LayoutHelper::VisibleRect::rightBottom();
cocos2d::Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1156,13 +1156,13 @@ void LayoutHelper::VisibleRect::setNodeNormalizedLT(Node* pNode, const cocos2d::
{
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(0, scrSize.height) - LayoutHelper::VisibleRect::leftTop();
cocos2d::Size vscrSize = LayoutHelper::VisibleRect::size();
Vec2 vscrSize = LayoutHelper::VisibleRect::size();
cocos2d::Point p = cocos2d::Vec2(vscrSize.width * ratio.x, vscrSize.height * ratio.y);
cocos2d::Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1177,13 +1177,13 @@ void LayoutHelper::VisibleRect::setNodeNormalizedLT(Node* pNode, const cocos2d::
void LayoutHelper::VisibleRect::setNodeNormalizedRT(Node* pNode, const cocos2d::Point& ratio)
{ // right top
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(scrSize.width, scrSize.height) - LayoutHelper::VisibleRect::rightTop();
cocos2d::Size vscrSize = LayoutHelper::VisibleRect::size();
Vec2 vscrSize = LayoutHelper::VisibleRect::size();
cocos2d::Point p = cocos2d::Vec2(vscrSize.width * ratio.x, vscrSize.height * ratio.y);
cocos2d::Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1197,13 +1197,13 @@ void LayoutHelper::VisibleRect::setNodeNormalizedRT(Node* pNode, const cocos2d::
void LayoutHelper::VisibleRect::setNodeNormalizedLB(Node* pNode, const cocos2d::Point& ratio)
{ // left bottom
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(0, 0) - LayoutHelper::VisibleRect::leftBottom();
cocos2d::Size vscrSize = LayoutHelper::VisibleRect::size();
Vec2 vscrSize = LayoutHelper::VisibleRect::size();
cocos2d::Point p = cocos2d::Vec2(vscrSize.width * ratio.x, vscrSize.height * ratio.y);
cocos2d::Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1217,13 +1217,13 @@ void LayoutHelper::VisibleRect::setNodeNormalizedLB(Node* pNode, const cocos2d::
void LayoutHelper::VisibleRect::setNodeNormalizedRB(Node* pNode, const cocos2d::Point& ratio)
{ // right bottom
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(scrSize.width, 0) - LayoutHelper::VisibleRect::rightBottom();
cocos2d::Size vscrSize = LayoutHelper::VisibleRect::size();
Vec2 vscrSize = LayoutHelper::VisibleRect::size();
cocos2d::Point p = cocos2d::Vec2(vscrSize.width * ratio.x, vscrSize.height * ratio.y);
cocos2d::Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{
@ -1238,13 +1238,13 @@ void LayoutHelper::VisibleRect::setNodeNormalizedRB(Node* pNode, const cocos2d::
void LayoutHelper::VisibleRect::setNodeNormalizedTop(Node* pNode, const float ratioTop)
{ // right top
CC_ASSERT(pNode);
cocos2d::Size scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
Vec2 scrSize = Director::getInstance()->getOpenGLView()->getDesignResolutionSize();
cocos2d::Point delta = cocos2d::Vec2(scrSize.width, scrSize.height) - LayoutHelper::VisibleRect::rightTop();
cocos2d::Size vscrSize = LayoutHelper::VisibleRect::size();
Vec2 vscrSize = LayoutHelper::VisibleRect::size();
float top = vscrSize.width * ratioTop;
cocos2d::Size size = pNode->getContentSize() * getScale2D(pNode);
Vec2 size = pNode->getContentSize() * getScale2D(pNode);
cocos2d::Point achorPoint = Vec2::ZERO;
if (!pNode->isIgnoreAnchorPointForPosition())
{

Some files were not shown because too many files have changed in this diff Show More