diff options
Diffstat (limited to 'examples/animation/main.cpp')
-rw-r--r-- | examples/animation/main.cpp | 8 |
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(); } |