Issue:
I have a image like below, I want to create paddles with different size, (blue, green, red, purple)
and each color has four sizes.
How can I correctly index the sprite?
// I tried to create a Frame, but don't know where to use it
for(let i = 0; i < 3; i++) {
new Phaser.Textures.Frame(resource, `short-${i}`, 0, x, y, 32, 16
new Phaser.Textures.Frame(resource, `medium-${i}`, 0, x + 32, y, 64, 16)
new Phaser.Textures.Frame(resource, `long-${i}`, 0, x + 96, y, 96, 16)
new Phaser.Textures.Frame(resource, `huge-${i}`, 0, x, y + 16, 128, 16)
}
I am watching tutorials on Youtube about Game development, I found a great resource but it’s in lua, not js.
Youtube Link
Solution:
Thanks @samme for the answer.
class MainScene extends Phaser.Scene {
preload() {
this.load.image('sprite', 'url');
this.load.once('filecomplete-image-sprite', () => {
this.textures.get('sprite').add('brick-blue', 0, 0, 0, 32, 16);
this.textures.get('sprite').add('brick-green', 0, 128, 0, 32, 16);
})
}
create() {
this.add.image(20, 20, 'sprite', 'brick-blue');
this.add.image(52, 20, 'sprite', 'brick-green');
}
}