Chapter 5 Question - How to extract bullets from image?
Closed this issue · 2 comments
Hello Boss :)
I didn't reach Mike, so I thought I may ask you.
I never did something with spritesheets before, so I'd like to ask you how I should extract the bullets from the spritesheet. Should I count the pixels and then put them in a sprite array or what?
Thank you for the answer
tobipch
Hiya there,
You should totally grab an array out of it (I've made this little tool as an aid).
Then use it like this:
blueBullet: [20, 53, 6, 6],
render: function() {
this.layer.drawRegion(this.images.spritesheet, this.blueBullet, this.x, this.y);
/* or using this.layer.drawImage */
}
Note that the bullet will not get centered - but I am leaving that to you :)
Cheers!
Hi,
Thank you for the fast response, it really helped me, as well as Spritie Cutie (Nice Tool BTW).
This Unfinished Game Challenge is very very good and I think it's better to learn than doing something from beginning, 'cause you see best practices as you code and you can implement things step by step by yourself, with some advices!
Keep going :)