134 lines
2.8 KiB
C
134 lines
2.8 KiB
C
|
|
// Copyright (c) 2016-2018 Easy2D - Nomango
|
|||
|
|
//
|
|||
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
// in the Software without restriction, including without limitation the rights
|
|||
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
// furnished to do so, subject to the following conditions:
|
|||
|
|
//
|
|||
|
|
// The above copyright notice and this permission notice shall be included in
|
|||
|
|
// all copies or substantial portions of the Software.
|
|||
|
|
//
|
|||
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
|
|
// THE SOFTWARE.
|
|||
|
|
|
|||
|
|
#pragma once
|
|||
|
|
#include "Action.h"
|
|||
|
|
#include "Image.h"
|
|||
|
|
|
|||
|
|
namespace easy2d
|
|||
|
|
{
|
|||
|
|
// ֡<><D6A1><EFBFBD><EFBFBD>
|
|||
|
|
class Animation
|
|||
|
|
: public RefCounter
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
typedef std::vector<Image*> Images;
|
|||
|
|
|
|||
|
|
Animation();
|
|||
|
|
|
|||
|
|
explicit Animation(
|
|||
|
|
const Images& frames /* <20>ؼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD> */
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
explicit Animation(
|
|||
|
|
float interval /* ֡<><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룩 */
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
explicit Animation(
|
|||
|
|
float interval, /* ֡<><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룩 */
|
|||
|
|
const Images& frames /* <20>ؼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD> */
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
virtual ~Animation();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӹؼ<D3B9>֡
|
|||
|
|
void Add(
|
|||
|
|
Image * frame /* <20>ؼ<EFBFBD>֡ */
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>ؼ<EFBFBD>֡
|
|||
|
|
void Add(
|
|||
|
|
const Images& frames /* <20>ؼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD> */
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// <20><>ȡ֡<C8A1><D6A1><EFBFBD><EFBFBD>
|
|||
|
|
float GetInterval() const;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD>ؼ<EFBFBD>֡
|
|||
|
|
const Images& GetFrames() const;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ÿһ֡<D2BB><D6A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void SetInterval(
|
|||
|
|
float interval /* ֡<><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룩 */
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// <20><>ȡ֡<C8A1><D6A1><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Animation * Clone() const;
|
|||
|
|
|
|||
|
|
// <20><>ȡ֡<C8A1><D6A1><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ת
|
|||
|
|
Animation * Reverse() const;
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
E2D_DISABLE_COPY(Animation);
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
float interval_;
|
|||
|
|
Images frames_;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>鶯<EFBFBD><E9B6AF>
|
|||
|
|
class Animate
|
|||
|
|
: public Action
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
Animate();
|
|||
|
|
|
|||
|
|
explicit Animate(
|
|||
|
|
Animation * animation
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
virtual ~Animate();
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
virtual Animation * GetAnimation() const;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>
|
|||
|
|
virtual void SetAnimation(
|
|||
|
|
Animation * animation
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
virtual Animate * Clone() const override;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ĵ<EFBFBD>ת
|
|||
|
|
virtual Animate * Reverse() const override;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>
|
|||
|
|
virtual void Reset() override;
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
E2D_DISABLE_COPY(Animate);
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
virtual void Initialize() override;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>¶<EFBFBD><C2B6><EFBFBD>
|
|||
|
|
virtual void Update() override;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
virtual void ResetTime() override;
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
UINT frame_index_;
|
|||
|
|
Animation * animation_;
|
|||
|
|
};
|
|||
|
|
}
|