aboutsummaryrefslogtreecommitdiff
path: root/examples/animation/main.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-11-21 08:39:28 +0800
committerchai <chaifix@163.com>2018-11-21 08:39:28 +0800
commitf440f7fb52ca62715504e4a3c7076456de40f7b8 (patch)
tree16d6bbaa9a6d42c6c57c193556ea0e1a881128a0 /examples/animation/main.cpp
parent9474767c68c48eff2618df80433b0b81ebf529c6 (diff)
*更新动画
Diffstat (limited to 'examples/animation/main.cpp')
-rw-r--r--examples/animation/main.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/animation/main.cpp b/examples/animation/main.cpp
index 033e499..741385a 100644
--- a/examples/animation/main.cpp
+++ b/examples/animation/main.cpp
@@ -19,6 +19,7 @@ Timer::Handler* hnd;
Texture* tex;
Shader* shader;
Animation anim;
+Animator animator;
const char* shader_code = R"(
#VERTEX_SHADER
Vertex vert(Vertex v)
@@ -42,7 +43,8 @@ void onLoad()
SpriteSheet ss = SpriteSheet(tex);
vector<Sprite*> frames = ss.createSprites(1, 19, 246, 238, Sprite::Origin::BottomCenter);
anim.addFrames(frames);
- anim.setSpeed(0.05);
+ anim.setSpeed(0.03);
+ animator.setAnimation(&anim);
}
void onEvent(Event* e)
@@ -54,7 +56,7 @@ void onEvent(Event* e)
void onUpdate(int ms)
{
- anim.update(ms / 1000.f);
+ animator.update(ms / 1000.f);
timer.update(ms);
}
@@ -64,7 +66,7 @@ void onDraw()
Mouse* m = Mouse::get();
int x, y;
m->getState(&x, &y);
- anim.render(x, y, 1, 1, 0);
+ animator.render(x, y, 1, 1, 0);
shader->unuse();
}