Sprite
#HelloGameDev #HelloErmine #HelloWorld2021
Sprite
เป็นการสร้าง object ที่ภาพมี animation โดยเราจะใช้คำสั่ง this.add.sprite(x,y,'key')
แต่เมื่อเราต้องการให้ภาพ animation นั้นมีระบบฟิสิกส์ ให้เราใช้ this.physics.add.sprite(x,y,'key')
ลงไปใน Create function
ตัวอย่าง
preload(){
this.load.spritesheet('bird','src/image/bird.png',
{ frameWidth: 410 , frameHeight: 310});
}
create(){
bird = this.add.sprite(425, 700, 'bird').setScale(0.5);
}
ผลลัพธ์ที่ได้

การหา frameWidth เเละ frameHeight
frameWidth
ความยาวรูป/จำนวนเฟรม
frameHeight
ความสูงของรูป

Last updated
Was this helpful?