mirror of https://github.com/axmolengine/axmol.git
Merge pull request #12786 from WenhaiLin/v3-animation-getCurrentFrame
Add Animate:getCurrentFrameIndex
This commit is contained in:
commit
8944e932a1
|
@ -2270,6 +2270,7 @@ Animate::Animate()
|
|||
, _executedLoops(0)
|
||||
, _animation(nullptr)
|
||||
, _frameDisplayedEvent(nullptr)
|
||||
, _currFrameIndex(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -2383,7 +2384,8 @@ void Animate::update(float t)
|
|||
float splitTime = _splitTimes->at(i);
|
||||
|
||||
if( splitTime <= t ) {
|
||||
AnimationFrame* frame = frames.at(i);
|
||||
_currFrameIndex = i;
|
||||
AnimationFrame* frame = frames.at(_currFrameIndex);
|
||||
frameToDisplay = frame->getSpriteFrame();
|
||||
static_cast<Sprite*>(_target)->setSpriteFrame(frameToDisplay);
|
||||
|
||||
|
|
|
@ -1439,6 +1439,11 @@ public:
|
|||
Animation* getAnimation() { return _animation; }
|
||||
const Animation* getAnimation() const { return _animation; }
|
||||
|
||||
/**
|
||||
* Gets the index of sprite frame currently displayed.
|
||||
* @return int the index of sprite frame currently displayed.
|
||||
*/
|
||||
int getCurrentFrameIndex() { return _currFrameIndex; }
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
|
@ -1462,6 +1467,7 @@ protected:
|
|||
std::vector<float>* _splitTimes;
|
||||
int _nextFrame;
|
||||
SpriteFrame* _origFrame;
|
||||
int _currFrameIndex;
|
||||
unsigned int _executedLoops;
|
||||
Animation* _animation;
|
||||
|
||||
|
|
2
web
2
web
|
@ -1 +1 @@
|
|||
Subproject commit fec945a7000ff31a7c206ca2ca7fd13707a2570a
|
||||
Subproject commit 048bf1f409b51fd3e8247ecaa61b987a4610fbd0
|
Loading…
Reference in New Issue