Initial commit
This commit is contained in:
commit
3ba46bc350
11 changed files with 18382 additions and 0 deletions
8
src/index.html
Normal file
8
src/index.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Phaser3 + Parceljs Template</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
18
src/main.ts
Normal file
18
src/main.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import Phaser from 'phaser'
|
||||
|
||||
import HelloWorldScene from './scenes/HelloWorldScene'
|
||||
|
||||
const config: Phaser.Types.Core.GameConfig = {
|
||||
type: Phaser.AUTO,
|
||||
width: 800,
|
||||
height: 600,
|
||||
physics: {
|
||||
default: 'arcade',
|
||||
arcade: {
|
||||
gravity: { y: 200 }
|
||||
}
|
||||
},
|
||||
scene: [HelloWorldScene]
|
||||
}
|
||||
|
||||
export default new Phaser.Game(config)
|
||||
39
src/scenes/HelloWorldScene.ts
Normal file
39
src/scenes/HelloWorldScene.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import Phaser from 'phaser'
|
||||
|
||||
export default class HelloWorldScene extends Phaser.Scene
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('hello-world')
|
||||
}
|
||||
|
||||
preload()
|
||||
{
|
||||
this.load.setBaseURL('http://labs.phaser.io')
|
||||
|
||||
this.load.image('sky', 'assets/skies/space3.png')
|
||||
this.load.image('logo', 'assets/sprites/phaser3-logo.png')
|
||||
this.load.image('red', 'assets/particles/red.png')
|
||||
}
|
||||
|
||||
create()
|
||||
{
|
||||
this.add.image(400, 300, 'sky')
|
||||
|
||||
const particles = this.add.particles('red')
|
||||
|
||||
const emitter = particles.createEmitter({
|
||||
speed: 100,
|
||||
scale: { start: 1, end: 0 },
|
||||
blendMode: 'ADD'
|
||||
})
|
||||
|
||||
const logo = this.physics.add.image(400, 100, 'logo')
|
||||
|
||||
logo.setVelocity(100, 200)
|
||||
logo.setBounce(1, 1)
|
||||
logo.setCollideWorldBounds(true)
|
||||
|
||||
emitter.startFollow(logo)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue