Phaser: Scenes

This post is part of a Phaser series. Click here to see the first post of the series.

Scenes are where we define our game, and we pass them as a property to the scene object to the configuration.

In particular, we can define

preload is t…


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

This post is part of a Phaser series. Click here to see the first post of the series.

Scenes are where we define our game, and we pass them as a property to the scene object to the configuration.

In particular, we can define

  • preload is the function where we can load external assets
  • create called when the game is first created, here we can define the GameObjects needed at the start of the game
  • update is the game event loop, where we define how the game works

GameObjects are a particular type of Phaser objects

Here’s an example of the first 2 events mentioned:

function preload() {

}

function create() {

}

new Phaser.Game({
  width: 450,
  height: 600,
  scene: {
    preload: preload,
    create: create
  }
})

Or, since each property in this case has the same name of the function:

new Phaser.Game({
  width: 450,
  height: 600,
  scene: {
    preload,
    create
  }
})


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2021-04-15T05:00:00+00:00) Phaser: Scenes. Retrieved from https://www.scien.cx/2021/04/15/phaser-scenes/

MLA
" » Phaser: Scenes." flaviocopes.com | Sciencx - Thursday April 15, 2021, https://www.scien.cx/2021/04/15/phaser-scenes/
HARVARD
flaviocopes.com | Sciencx Thursday April 15, 2021 » Phaser: Scenes., viewed ,<https://www.scien.cx/2021/04/15/phaser-scenes/>
VANCOUVER
flaviocopes.com | Sciencx - » Phaser: Scenes. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/15/phaser-scenes/
CHICAGO
" » Phaser: Scenes." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2021/04/15/phaser-scenes/
IEEE
" » Phaser: Scenes." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/04/15/phaser-scenes/. [Accessed: ]
rf:citation
» Phaser: Scenes | flaviocopes.com | Sciencx | https://www.scien.cx/2021/04/15/phaser-scenes/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.