Lamberto Posted December 14, 2016 Share Posted December 14, 2016 hello, is the isCurrentAnimation() broken in version 4.0? it always returns false to me Quote Link to comment Share on other sites More sharing options...
obiot Posted December 14, 2016 Share Posted December 14, 2016 it's not supposed to, we even added a small test unit for it (that is passing) : https://github.com/melonjs/melonJS/blob/master/tests/spec/sprite-spec.js#L27-L28 Quote Link to comment Share on other sites More sharing options...
Lamberto Posted December 15, 2016 Author Share Posted December 15, 2016 well, the test unit may be too simple for intercepting the bug. Quote Link to comment Share on other sites More sharing options...
obiot Posted December 15, 2016 Share Posted December 15, 2016 Can you maybe describe what you are doing ? Quote Link to comment Share on other sites More sharing options...
Lamberto Posted December 15, 2016 Author Share Posted December 15, 2016 nothing fancy. take a look at this simple test case http://www.officinepixel.com/test/testCase_isCurrentAnimation/ look at the console output. the current animation name sometime is the right string and sometime is a number, so, isCurrentAnimation() simply fails Quote Link to comment Share on other sites More sharing options...
obiot Posted December 15, 2016 Share Posted December 15, 2016 ah ! interesting i'll check that tomorrow ! Quote Link to comment Share on other sites More sharing options...
Parasyte Posted December 15, 2016 Share Posted December 15, 2016 I think this is the problem: https://github.com/melonjs/melonJS/blob/50597e86b39e5dd7a0efaf8aa74de1142013ffaa/src/renderable/sprite.js#L378-L379 When setting an animation, it replaces the name of the first frame with the animation name. As the animation cycles, the current frame will not have the name of the animation. This [incomplete] workaround was added here: https://github.com/melonjs/melonJS/commit/a0e084ad68c58f6a9a0599982c6d4b39f02176f7 Quote Link to comment Share on other sites More sharing options...
obiot Posted December 16, 2016 Share Posted December 16, 2016 still weird though that this does not happen all the time.... maybe when it cycles through an animation, and loop back to the first frame ? i will try to reproduce it in our test unit first. Quote Link to comment Share on other sites More sharing options...
obiot Posted December 16, 2016 Share Posted December 16, 2016 ok, found it (I think). sometimes, the name got overwritten in the setAnimationFrame method (I guess by that line) : https://github.com/melonjs/melonJS/blob/master/src/renderable/sprite.js#L420 here is my quick fix for it, give it a try on your side to confirm it does the trick : https://github.com/melonjs/melonJS/commit/54ebbbabc5e1bf980d7093310859a6d9511b2d00 we will have this ticket then to properly fix it (something with how the data is stored/used is wrong): https://github.com/melonjs/melonJS/issues/824 Quote Link to comment Share on other sites More sharing options...
Lamberto Posted December 16, 2016 Author Share Posted December 16, 2016 The quick fix does the trick nicely. Thank you very much! I've found another weird thing. http://www.officinepixel.com/test/testCase_flip/ It seems me.Sprite.flipX is deprecated and when is set true the sprite disappears. I've not found any information in documentation on this fact. Is flipX (and flipY) really deprecated? If so what's the alternative? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.