mirror of https://github.com/axmolengine/axmol.git
commit
01e1508239
|
@ -1,4 +1,6 @@
|
|||
cocos2d-x-3.2 ??
|
||||
[FIX] Animation3D: getOrCreate is deprecated and replaced with Animation3D::create
|
||||
[FIX] Animate3D: setSpeed() accept negtive value, which means play reverse, getPlayback and setPlayBack are deprecated
|
||||
[FIX] GLView: cursor position is not correct if design resolution is different from device resolution
|
||||
[FIX] Label: color can not be set correctly if using system font
|
||||
[FIX] Node: setRotation3D not work based on anchor point
|
||||
|
|
|
@ -66,12 +66,12 @@ Animate3D* Animate3D::clone() const
|
|||
auto animate = const_cast<Animate3D*>(this);
|
||||
auto copy = Animate3D::create(animate->_animation);
|
||||
|
||||
copy->_speed = _speed;
|
||||
copy->_absSpeed = _absSpeed;
|
||||
copy->_weight = _weight;
|
||||
copy->_elapsed = _elapsed;
|
||||
copy->_start = _start;
|
||||
copy->_last = _last;
|
||||
copy->_playBack = _playBack;
|
||||
copy->_playReverse = _playReverse;
|
||||
copy->setDuration(animate->getDuration());
|
||||
|
||||
return copy;
|
||||
|
@ -81,7 +81,7 @@ Animate3D* Animate3D::clone() const
|
|||
Animate3D* Animate3D::reverse() const
|
||||
{
|
||||
auto animate = clone();
|
||||
animate->_playBack = !animate->_playBack;
|
||||
animate->_playReverse = !animate->_playReverse;
|
||||
return animate;
|
||||
}
|
||||
|
||||
|
@ -112,16 +112,16 @@ void Animate3D::startWithTarget(Node *target)
|
|||
//! called every frame with it's delta time. DON'T override unless you know what you are doing.
|
||||
void Animate3D::step(float dt)
|
||||
{
|
||||
ActionInterval::step(dt * _speed);
|
||||
ActionInterval::step(dt * _absSpeed);
|
||||
}
|
||||
|
||||
void Animate3D::update(float t)
|
||||
{
|
||||
if (_target)
|
||||
if (_target && _weight > 0.f)
|
||||
{
|
||||
float transDst[3], rotDst[4], scaleDst[3];
|
||||
float* trans = nullptr, *rot = nullptr, *scale = nullptr;
|
||||
if (_playBack)
|
||||
if (_playReverse)
|
||||
t = 1 - t;
|
||||
|
||||
t = _start + t * _last;
|
||||
|
@ -149,13 +149,29 @@ void Animate3D::update(float t)
|
|||
|
||||
}
|
||||
|
||||
float Animate3D::getSpeed() const
|
||||
{
|
||||
return _playReverse ? -_absSpeed : _absSpeed;
|
||||
}
|
||||
void Animate3D::setSpeed(float speed)
|
||||
{
|
||||
_absSpeed = fabsf(speed);
|
||||
_playReverse = speed < 0;
|
||||
}
|
||||
|
||||
void Animate3D::setWeight(float weight)
|
||||
{
|
||||
CCASSERT(weight >= 0.0f, "invalid weight");
|
||||
_weight = fabsf(weight);
|
||||
}
|
||||
|
||||
Animate3D::Animate3D()
|
||||
: _speed(1)
|
||||
: _absSpeed(1.f)
|
||||
, _weight(1.f)
|
||||
, _start(0.f)
|
||||
, _last(1.f)
|
||||
, _animation(nullptr)
|
||||
, _playBack(false)
|
||||
, _playReverse(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "base/ccMacros.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "base/CCPlatformMacros.h"
|
||||
#include "2d/CCActionInterval.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -66,17 +67,17 @@ public:
|
|||
|
||||
virtual void update(float t) override;
|
||||
|
||||
/**get & set speed */
|
||||
float getSpeed() const { return _speed; }
|
||||
void setSpeed(float speed) { _speed = speed; }
|
||||
/**get & set speed, negative speed means playing reverse */
|
||||
float getSpeed() const;
|
||||
void setSpeed(float speed);
|
||||
|
||||
/**get & set blend weight*/
|
||||
/**get & set blend weight, weight must positive*/
|
||||
float getWeight() const { return _weight; }
|
||||
void setWeight(float weight) { _weight = weight; }
|
||||
void setWeight(float weight);
|
||||
|
||||
/**get & set play back*/
|
||||
bool getPlayBack() const { return _playBack; }
|
||||
void setPlayBack(bool playBack) { _playBack = playBack; }
|
||||
/**get & set play reverse*/
|
||||
CC_DEPRECATED_ATTRIBUTE bool getPlayBack() const { return _playReverse; }
|
||||
CC_DEPRECATED_ATTRIBUTE void setPlayBack(bool reverse) { _playReverse = reverse; }
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
|
@ -86,11 +87,11 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
protected:
|
||||
Animation3D* _animation; //animation data
|
||||
|
||||
float _speed; //playing speed
|
||||
float _absSpeed; //playing speed
|
||||
float _weight; //blend weight
|
||||
float _start; //start time 0 - 1, used to generate sub Animate3D
|
||||
float _last; //last time 0 - 1, used to generate sub Animate3D
|
||||
bool _playBack; // is playing back
|
||||
bool _playReverse; // is playing reverse
|
||||
std::map<Bone*, Animation3D::Curve*> _boneCurves; //weak ref
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Animation3D* Animation3D::getOrCreate(const std::string& fileName, const std::string& animationName)
|
||||
Animation3D* Animation3D::create(const std::string& fileName, const std::string& animationName)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
std::string key = fullPath + "#" + animationName;
|
||||
|
|
|
@ -59,8 +59,10 @@ public:
|
|||
~Curve();
|
||||
};
|
||||
|
||||
/**read all animation or only the animation with given animationName? animationName == "" read all.*/
|
||||
static Animation3D* getOrCreate(const std::string& filename, const std::string& animationName = "");
|
||||
/**read all animation or only the animation with given animationName? animationName == "" read the first.*/
|
||||
static Animation3D* create(const std::string& filename, const std::string& animationName = "");
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE static Animation3D* getOrCreate(const std::string& filename, const std::string& animationName = ""){ return create(filename, animationName); }
|
||||
|
||||
/**get duration*/
|
||||
float getDuration() const { return _duration; }
|
||||
|
|
|
@ -342,7 +342,7 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
_meshCommand.setDepthTestEnabled(true);
|
||||
if (_skin)
|
||||
{
|
||||
_meshCommand.setMatrixPaletteSize(_skin->getMatrixPaletteSize());
|
||||
_meshCommand.setMatrixPaletteSize((int)_skin->getMatrixPaletteSize());
|
||||
_meshCommand.setMatrixPalette(_skin->getMatrixPalette());
|
||||
}
|
||||
//support tint and fade
|
||||
|
|
|
@ -402,9 +402,9 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t
|
|||
Skin *skin = static_cast<Skin *>(node);
|
||||
skin->updateTransform();
|
||||
|
||||
bool blendDirty = bone->isBlendDirty();
|
||||
BlendFunc func = bone->getBlendFunc();
|
||||
|
||||
if (blendDirty)
|
||||
if (func.src != _blendFunc.src || func.dst != _blendFunc.dst)
|
||||
{
|
||||
skin->setBlendFunc(bone->getBlendFunc());
|
||||
}
|
||||
|
|
|
@ -546,24 +546,23 @@ void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p)
|
|||
addChild(sprite);
|
||||
sprite->setPosition( Vec2( p.x, p.y) );
|
||||
|
||||
auto animation = Animation3D::getOrCreate(fileName);
|
||||
auto animation = Animation3D::create(fileName);
|
||||
if (animation)
|
||||
{
|
||||
auto animate = Animate3D::create(animation);
|
||||
if(std::rand() %3 == 0)
|
||||
{
|
||||
animate->setPlayBack(true);
|
||||
}
|
||||
bool inverse = (std::rand() % 3 == 0);
|
||||
|
||||
int rand2 = std::rand();
|
||||
float speed = 1.0f;
|
||||
if(rand2 % 3 == 1)
|
||||
{
|
||||
animate->setSpeed(animate->getSpeed() + CCRANDOM_0_1());
|
||||
speed = animate->getSpeed() + CCRANDOM_0_1();
|
||||
}
|
||||
else if(rand2 % 3 == 2)
|
||||
{
|
||||
animate->setSpeed(animate->getSpeed() - 0.5 * CCRANDOM_0_1());
|
||||
speed = animate->getSpeed() - 0.5 * CCRANDOM_0_1();
|
||||
}
|
||||
animate->setSpeed(inverse ? -speed : speed);
|
||||
|
||||
sprite->runAction(RepeatForever::create(animate));
|
||||
}
|
||||
|
@ -652,7 +651,7 @@ void Animate3DTest::addSprite3D()
|
|||
sprite->setPosition(Vec2(s.width * 4.f / 5.f, s.height / 2.f));
|
||||
addChild(sprite);
|
||||
_sprite = sprite;
|
||||
auto animation = Animation3D::getOrCreate(fileName);
|
||||
auto animation = Animation3D::create(fileName);
|
||||
if (animation)
|
||||
{
|
||||
auto animate = Animate3D::create(animation, 0.f, 1.933f);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7fc616bcbcfd9b60e8b1188ba974e4f66621beb8
|
||||
Subproject commit ce3e25bcd273eaacd516d179587997ce8f62df70
|
Loading…
Reference in New Issue