TileSprite
#HelloGameDev #HelloErmine #HelloWorld2021
TileSprite
เป็นการสร้าง object ส่วนใหญ่ใช้ในการทำให้รูปภาพพื้นหลังของเรานั้นเคลื่อนไหว ใช้คำสั่ง
objectName = this.add.tileSprite(x, y, width, height, 'key').setOrigin(x, y);
ตัวอย่าง
preload(){
this.load.image('bg', 'src/image/wild.png');
}
create(){
background = this.add.tileSprite(0, 0, 850, 1400, 'bg').setOrigin(0, 0);
}
update(){
background.tilePositionY -= 10;
}
ผลลัพธ์ที่ได้
Last updated
Was this helpful?