Ninjadoodle Posted April 17, 2018 Share Posted April 17, 2018 Hi @enpu I'm trying to insert a sprite into an anim class (as if it were a container), but it doesn't display the sprite correctly. It seems like its not putting the sprite at the correct co-ordinates. Let me know if you need more info on this Quote Link to comment Share on other sites More sharing options...
enpu Posted April 18, 2018 Share Posted April 18, 2018 @Ninjadoodle game.addAsset('anim1.png'); game.addAsset('anim2.png'); game.addAsset('anim3.png'); game.addAsset('sprite.png'); game.createScene('Main', { init: function() { var anim = new game.Animation([ 'anim1.png', 'anim2.png', 'anim3.png' ]); anim.play(); anim.addTo(this.stage); var sprite = new game.Sprite('sprite.png'); sprite.position.set(100, 100); sprite.addTo(anim); } }); Seems to be working fine here. Can you give me code example? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted April 22, 2018 Author Share Posted April 22, 2018 Hi @enpu In the case below, I'm putting the anchor point of the anim into the center. As far I can tell, when I insert the sprite, the sprite's top left corner should sit against the anim's center. It however sits as if the anim's anchor was still at (0, 0). this.anim = new game.Animation([ 'tile1.png', 'tile2.png', 'tile3.png', 'tile4.png' ]); this.anim.speed = 4; this.anim.play(frame); this.anim.anchorCenter(); this.anim.position.set(x, y); this.anim.interactive = true; this.anim.addTo(game.scene.mg); var sprite = new game.Sprite('tile.png'); sprite.addTo(this.anim); Quote Link to comment Share on other sites More sharing options...
enpu Posted April 25, 2018 Share Posted April 25, 2018 @Ninjadoodle Just pushed fix for this, can you update to latest dev version and let me know how it works now. Thanks! Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted April 25, 2018 Author Share Posted April 25, 2018 @enpu - Works well now, thank you for the fix 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.