From f440f7fb52ca62715504e4a3c7076456de40f7b8 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 21 Nov 2018 08:39:28 +0800 Subject: =?UTF-8?q?*=E6=9B=B4=E6=96=B0=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/animation/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'examples/animation/main.cpp') 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 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(); } -- cgit v1.1-26-g67d0