From 05899d5f6a2e414d3d2eadb606a956f2b5eaaf65 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 2 Apr 2014 11:48:49 +0800 Subject: [PATCH] Fixed #4637: Add loop parameter to Animation::initWithSpriteFrames function --- cocos/2d/CCAnimation.cpp | 4 ++-- cocos/2d/CCAnimation.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCAnimation.cpp b/cocos/2d/CCAnimation.cpp index 20c965a648..0544a33c7f 100644 --- a/cocos/2d/CCAnimation.cpp +++ b/cocos/2d/CCAnimation.cpp @@ -118,10 +118,10 @@ bool Animation::init() return true; } -bool Animation::initWithSpriteFrames(const Vector& frames, float delay/* = 0.0f*/) +bool Animation::initWithSpriteFrames(const Vector& frames, float delay, unsigned int loops) { - _loops = 1; _delayPerUnit = delay; + _loops = loops; for (auto& spriteFrame : frames) { diff --git a/cocos/2d/CCAnimation.h b/cocos/2d/CCAnimation.h index fbb25c584a..ea8efd12e2 100644 --- a/cocos/2d/CCAnimation.h +++ b/cocos/2d/CCAnimation.h @@ -224,7 +224,7 @@ CC_CONSTRUCTOR_ACCESS: /** Initializes a Animation with frames and a delay between frames @since v0.99.5 */ - bool initWithSpriteFrames(const Vector& arrayOfSpriteFrameNames, float delay = 0.0f); + bool initWithSpriteFrames(const Vector& arrayOfSpriteFrameNames, float delay = 0.0f, unsigned int loops = 1); /** Initializes a Animation with AnimationFrame @since v2.0