tomato

Picture content


Official website address

Reference article

A complete games are partakers of the scene, about four scenarios are as follows:

  • Load - show the progress bar and loading animation, the main operation to load the game resources, such as images, audio, etc.
  • Start - Display the Start button, activity rules, it is designed to allow players to have started active operations
  • Game - in this scenario, the core part of the main logic of the game
  • End - to show the game the final score, ranking, etc.

About to play again, there are two ways, one is back to the beginning scene, that is to say once again points to start the game, this time you can take a look at the rules of games; the other is the direct start the game.

Officially begin

1. Create an instance

The introduction of Phaser.js, create the instance of the game

2. Define the scene, the scene collusion

Each scene is a function, can be added to the game scene by game.state.add.

Each scene has its own life cycle, is commonly used in the life cycle of preload (load), create (ready), update (refresh cycle), render (rendering is complete)

  • preload - although we have pre-loaded scene, but if you want to reduce the time to load when entering the page, you can share some of the other scenes, only need to add preload method in other scenes can be
  • create - if there is preload method, this method will be executed after loading is completed; otherwise, this method will be executed directly when entering the scene
  • update - Method update cycle performed automatically, for example in the play scene update method to detect whether two objects can contact
  • render - method performed after completion of rendering, for example, an outline edge of an object in this process, to facilitate the observation of the object region collide

Load Resources

Operating load resources should be placed preload the stage to perform, when the preload of the resource is loaded, the preload will enter the scene create stage

Add the page is loaded minimum display time

In general, the game will be put in a loading interface LOGO, used as a display of publicity, so if you need to load resources are small, it is possible to load flash across the screen. Thus, according to experience, show sets a minimum time (e.g., three seconds), before not yet reached the minimum display time, even if the resource has been loaded, the load will not leave the scene.

Other specific api, such as input, animation, physics engines can see the official website api, additional official website also has rich examples.

api find this site to find a more convenient api, support fuzzy search.

Making your first Phaser 2 game

This page total views

Original: Large column  tomato


Guess you like

Origin www.cnblogs.com/petewell/p/11585142.html