-
-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: assets.ts, assets/index.js
- Loading branch information
1 parent
0fdc3b9
commit d2d911f
Showing
6 changed files
with
216 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# assets/autoload/phaser | ||
|
||
Images placed anywhere under assets/autoload/phaser will be loaded into Phaser when the game begins. | ||
|
||
## autoloaded images: Phaser keys | ||
|
||
Phaser requires a 'key' to access images, e.g., | ||
|
||
``` | ||
this.display.loadTexture("myKey"); | ||
``` | ||
|
||
When using an autoloaded image, the basename of the file will be used as the key in Phaser. | ||
|
||
### Example | ||
|
||
If /assets/autoload/phaser/apples/apple1.png is a valid path, it will be loaded **for you** into Phaser as follows: | ||
|
||
``` | ||
// NOTE: This is done FOR YOU when using autoloading. | ||
phaser.load.image('apple1', '/assets/autoload/phaser/apple/apple1.png'); | ||
``` | ||
|
||
The basename of the file - "apple1" - is the Phaser key, so you'll use the image like this: | ||
|
||
``` | ||
this.display.loadTexture("apple1"); | ||
``` | ||
|
||
### Troubleshooting | ||
|
||
Because the file basenames are used as Phaser keys, all basenames under assets/autoload/phaser must be unique. | ||
|
||
For example, including these two images in the project will cause an error to be thrown, because they have the same basename. | ||
|
||
``` | ||
/assets/autoload/phaser/monster/scary.png | ||
/assets/autoload/phaser/head/hair/morning/scary.png | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters