-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Scott Westover <[email protected]>
- Loading branch information
1 parent
8941178
commit 9792a7b
Showing
26 changed files
with
229,527 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode", "ritwickdey.LiveServer"] | ||
} |
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,11 @@ | ||
{ | ||
"eslint.format.enable": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"prettier.singleQuote": true, | ||
"prettier.semi": true, | ||
"editor.formatOnSave": true, | ||
"cSpell.words": ["anims"] | ||
} |
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,17 @@ | ||
# Phaser 3 - Animation Completion Event Demo | ||
|
||
![demo](docs/example.gif) | ||
|
||
A quick demo of how you can use the built in events of Phaser 3 to know when an animation is completed, that way you can use that event to perform some additional game logic. | ||
|
||
For a detailed walkthrough, checkout my video on YouTube here: | ||
|
||
[<img src="https://i.ytimg.com/vi/W-INH27SjKc/hqdefault.jpg">](https://youtu.be/W-INH27SjKc "Phaser 3 Mastery: How to Listen and React to Animation Completion Events") | ||
|
||
Link to live demo: | ||
|
||
[Animation Completion Event Demo](https://devshareacademy.github.io/code-examples-from-my-video-content/phaser-3/animation-completion-events/index.html) | ||
|
||
## Credit | ||
|
||
The spritesheet that was used in this demo were created by [Essssam](https://essssam.itch.io/rocky-roads). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
phaser-3/3.70/draggable-demo/assets/starfighter/public-license.txt
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,23 @@ | ||
Artwork created by Luis Zuno (@ansimuz) | ||
|
||
|
||
LICENSE: | ||
You may use these assets in personal or commercial projects. You can modify these assets to suit your needs. You can re-distribute the file. | ||
Credit no required but appreciated it. | ||
|
||
____________________ | ||
|
||
LINKS | ||
|
||
Twitter @ansimuz | ||
|
||
Support my work at Patreon https://www.patreon.com/ansimuz | ||
|
||
Buy my stuff https://ansimuz.itch.io/ | ||
|
||
Get more Free Assetslike these at: http://www.ansimuz.com | ||
|
||
|
||
____________________ | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Phaser 3 - Draggable Objects Demo</title> | ||
<style> | ||
html, | ||
body, | ||
.container { | ||
margin: 0px; | ||
height: 100vh; | ||
width: 100vw; | ||
overflow: hidden; | ||
background: #d7d7d7; | ||
} | ||
</style> | ||
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script> | ||
</head> | ||
<body> | ||
<div class="container" id="game-container"></div> | ||
<script type="module" src="src/main.js"></script> | ||
</body> | ||
</html> |
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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "es6", | ||
"target": "es2017", | ||
"checkJs": true | ||
} | ||
} |
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 @@ | ||
export default window.Phaser; |
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,73 @@ | ||
import Phaser from './lib/phaser.js'; | ||
|
||
const ASSETS = { | ||
BACKGROUND: { key: 'BACKGROUND', path: 'background.png' }, | ||
SHIP: { key: 'SHIP', path: 'ship-a1.png' }, | ||
ROCK: { key: 'ROCK', path: 'big-a.png' }, | ||
}; | ||
|
||
export class Game extends Phaser.Scene { | ||
constructor() { | ||
super({ key: 'Game' }); | ||
} | ||
|
||
preload() { | ||
this.load.setPath('assets/starfighter'); | ||
Object.values(ASSETS).forEach((asset) => { | ||
this.load.image(asset.key, asset.path); | ||
}); | ||
} | ||
|
||
create() { | ||
this.add | ||
.image( | ||
this.scale.width / 2, | ||
this.scale.height / 2, | ||
ASSETS.BACKGROUND.key, | ||
0 | ||
) | ||
.setAngle(-90) | ||
.setAlpha(0.7) | ||
.setScale(2.5); | ||
const ship = this.add | ||
.image(this.scale.width / 2, this.scale.height - 200, ASSETS.SHIP.key, 0) | ||
.setScale(3); | ||
ship.setInteractive({ | ||
draggable: true, | ||
}); | ||
ship.on('drag', (pointer, dragX, dragY) => { | ||
console.log(pointer); | ||
console.log(dragX, dragY); | ||
ship.setPosition(dragX, dragY); | ||
}); | ||
|
||
const rock = this.add | ||
.image(this.scale.width / 2, 150, ASSETS.ROCK.key, 0) | ||
.setScale(3); | ||
|
||
rock.setInteractive({ | ||
draggable: true, | ||
}); | ||
|
||
rock.on('drag', (pointer, x, y) => { | ||
rock.x = x; | ||
rock.y = y; | ||
}); | ||
} | ||
} | ||
|
||
const gameConfig = { | ||
type: Phaser.CANVAS, | ||
pixelArt: true, | ||
scale: { | ||
parent: 'game-container', | ||
width: window.innerWidth, //1080, | ||
height: window.innerHeight, //1920, | ||
autoCenter: Phaser.Scale.CENTER_BOTH, | ||
mode: Phaser.Scale.RESIZE, | ||
}, | ||
backgroundColor: '#000000', | ||
scene: [Game], | ||
}; | ||
|
||
const game = new Phaser.Game(gameConfig); |
Oops, something went wrong.