BunBunBun Posted February 25, 2015 Share Posted February 25, 2015 I have the animation of hero in one spritesheet file: spritesheet1.png preload:game.load.atlasJSONHash('spritesheet1', 'assets/entities/spritesheet1.png', 'assets/entities/spritesheet1.json');create:var hero = game.add.sprite(100, 100, 'spritesheet1');hero.animations.add('animName1', Phaser.Animation.generateFrameNames('animName1_', 0, 16, '', 4), 30);hero.animations.play('animName1', 30, true); also I have the "health bar" at that spitesheet1.png How is better to add that sprite from spritesheet? I do like that:var healthBar = game.add.sprite(250, 270, 'spritesheet1');healthBar.animations.add('healthBar', Phaser.Animation.generateFrameNames('healthBar_', 0, 0, '', 4), 30);healthBar.animations.play('healthBar');and I think that it's no a good way, may be is there a simple way to do? Yes, I know that I can load the healtBar as separate image (healthBar.png), but I want to keep all art in one spritesheet. Link to comment Share on other sites More sharing options...
rich Posted February 25, 2015 Share Posted February 25, 2015 What is the frame name of your healthBar? (open the json and have a look). Link to comment Share on other sites More sharing options...
BunBunBun Posted February 25, 2015 Author Share Posted February 25, 2015 just "healthBar_0000" Link to comment Share on other sites More sharing options...
rich Posted February 25, 2015 Share Posted February 25, 2015 Have you tried this?var healthBar = game.add.sprite(250, 270, 'spritesheet1', 'healthBar_0000'); BunBunBun 1 Link to comment Share on other sites More sharing options...
BunBunBun Posted February 26, 2015 Author Share Posted February 26, 2015 Thanks a lot, that is exactly what I need! Link to comment Share on other sites More sharing options...
Recommended Posts