KorokEngine / Korok

korok.io - golang game engine
zlib License
624 stars 65 forks source link

Bug Report: Animation Loops #38

Closed inclyc closed 5 years ago

inclyc commented 5 years ago

It seems that after setting the value of loop to true, the actual rendering result does not loop, but stops after playing once.

At commit 74f7926

@ntop001

ntop001 commented 5 years ago

@Enzyme125 Did you mean the Animation-Loop in FlipbookComp ? I have run some test code in https://github.com/KorokEngine/beta-demo/tree/master/sprite_anim, it works well. Can you show me more code or an example?

inclyc commented 5 years ago

I used the same code(https://github.com/KorokEngine/beta-demo/tree/master/sprite_anim) and official installation method(go get korok.io/korok). It looks like: rt.gif.gif

As you can see, the hero only shakes his arm once.

go env:

set GOARCH=amd64
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Enzyme125\go
set GORACE=
set GOROOT=C:\Go

The program output:

3.2.1 Win32 WGL EGL MinGW
2019/05/11 17:33:07 Game Start! Hello, Korok Engine
2019/05/11 17:33:07 Load table: 8
2019/05/11 17:33:07 0 table -  *game.ScriptTable
2019/05/11 17:33:07 1 table -  *game.TagTable
2019/05/11 17:33:07 2 table -  *gfx.SpriteTable
2019/05/11 17:33:07 3 table -  *gfx.MeshTable
2019/05/11 17:33:07 4 table -  *gfx.TransformTable
2019/05/11 17:33:07 5 table -  *gfx.TextTable
2019/05/11 17:33:07 6 table -  *effect.ParticleSystemTable
2019/05/11 17:33:07 7 table -  *frame.FlipbookTable
2019/05/11 17:33:10 alloc shader id:(1, 3) 
2019/05/11 17:33:10 bind attr: 1 => xyuv 
2019/05/11 17:33:10 bind attr: 0 => rgba 
2019/05/11 17:33:10 alloc uniform: (1, 0) => proj 
2019/05/11 17:33:10 alloc uniform: (2, 1) => tex 
2019/05/11 17:33:10 alloc shader id:(2, 6) 
2019/05/11 17:33:10 bind attr: 1 => xyuv 
2019/05/11 17:33:10 bind attr: 0 => rgba 
2019/05/11 17:33:10 alloc uniform: (3, 0) => proj 
2019/05/11 17:33:10 alloc uniform: (4, 1) => model 
2019/05/11 17:33:10 alloc uniform: (5, 2) => tex 
2019/05/11 17:33:10 alloc shader id:(3, 9) 
2019/05/11 17:33:10 bind attr: 1 => xyuv 
2019/05/11 17:33:10 bind attr: 0 => rgba 
2019/05/11 17:33:10 alloc uniform: (6, 0) => projection 
2019/05/11 17:33:10 alloc uniform: (7, 1) => tex 
2019/05/11 17:33:10 alloc index-buffer: (1, 1)
2019/05/11 17:33:10 alloc vertex-buffer: (1, 2)
2019/05/11 17:33:10 font img bounds: (0,0)-(999,54)
2019/05/11 17:33:10 alloc texture id: (1, 1)
2019/05/11 17:33:10 dbg init w,h 0 0
2019/05/11 17:33:10 load file:hero.png
2019/05/11 17:33:10 alloc texture id: (2, 2)
2019/05/11 17:33:10 Load Feature: 5
2019/05/11 17:33:10 0  feature -  *gfx.SpriteRenderFeature
2019/05/11 17:33:10 1  feature -  *gfx.MeshRenderFeature
2019/05/11 17:33:10 2  feature -  *gfx.TextRenderFeature
2019/05/11 17:33:10 3  feature -  *gui.UIRenderFeature
2019/05/11 17:33:10 4  feature -  *effect.ParticleRenderFeature
2019/05/11 17:33:10 alloc index-buffer: (2, 3)
2019/05/11 17:33:10 alloc vertex-buffer: (2, 4)
2019/05/11 17:33:26 window focuse changed !! false
2019/05/11 17:36:11 window focuse changed !! true
2019/05/11 17:36:16 window focuse changed !! false
2019/05/11 17:36:18 window focuse changed !! true
2019/05/11 17:36:32 window focuse changed !! false
2019/05/11 17:36:35 window focuse changed !! true
2019/05/11 17:36:36 window focuse changed !! false
2019/05/11 17:39:58 window focuse changed !! true
2019/05/11 17:40:03 window focuse changed !! false
2019/05/11 17:40:15 window focuse changed !! true
2019/05/11 17:40:29 window focuse changed !! false
2019/05/11 17:42:02 game paused..
2019/05/11 17:43:08 game resumed..
2019/05/11 17:43:08 window focuse changed !! true
2019/05/11 17:43:09 window focuse changed !! false
2019/05/11 17:43:18 window focuse changed !! true
2019/05/11 17:43:20 window focuse changed !! false
2019/05/11 17:43:21 window focuse changed !! true
2019/05/11 17:43:32 window focuse changed !! false
2019/05/11 17:44:51 window focuse changed !! true
2019/05/11 17:44:52 window focuse changed !! false

@ntop001

ntop001 commented 5 years ago

@Enzyme125 Hello, the demo project has some bugs, it used some old、outdated API. Changed the following code:

fb := korok.Flipbook.NewComp(hero)
fb.SetRate(.2)

to

fb := korok.Flipbook.NewComp(hero)
fb.SetRate(.2)  
fb.SetLoop(true, frame.Restart)

The default animation does not loop, I have fixed the bug in latest commit. Thanks for your prompt reply.