|
@@ -2,6 +2,8 @@ import Phaser from 'phaser'
|
|
import Gate from "./Objects/Gate";
|
|
import Gate from "./Objects/Gate";
|
|
import Switch from "./Objects/Switch";
|
|
import Switch from "./Objects/Switch";
|
|
import Button from './Objects/Button';
|
|
import Button from './Objects/Button';
|
|
|
|
+//import Player from "./Objects/Player";
|
|
|
|
+
|
|
|
|
|
|
export default class HelloWorldScene extends Phaser.Scene {
|
|
export default class HelloWorldScene extends Phaser.Scene {
|
|
//Sprite creation
|
|
//Sprite creation
|
|
@@ -16,8 +18,8 @@ export default class HelloWorldScene extends Phaser.Scene {
|
|
// private gatesA?: Phaser.Physics.Arcade.Group;
|
|
// private gatesA?: Phaser.Physics.Arcade.Group;
|
|
private platforms?: Phaser.Physics.Arcade.StaticGroup;
|
|
private platforms?: Phaser.Physics.Arcade.StaticGroup;
|
|
private boxes?: Phaser.Physics.Arcade.StaticGroup;
|
|
private boxes?: Phaser.Physics.Arcade.StaticGroup;
|
|
- private player1?: Phaser.Physics.Arcade.Sprite;
|
|
|
|
- private player2?: Phaser.Physics.Arcade.Sprite;
|
|
|
|
|
|
+ private player1!: Phaser.Physics.Arcade.Sprite;
|
|
|
|
+ private player2!: Phaser.Physics.Arcade.Sprite;
|
|
private cursors?: Phaser.Types.Input.Keyboard.CursorKeys;
|
|
private cursors?: Phaser.Types.Input.Keyboard.CursorKeys;
|
|
//Scene Transition
|
|
//Scene Transition
|
|
private nextScene?: Phaser.GameObjects.Text;
|
|
private nextScene?: Phaser.GameObjects.Text;
|
|
@@ -218,6 +220,9 @@ export default class HelloWorldScene extends Phaser.Scene {
|
|
repeat: -1,
|
|
repeat: -1,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
this.physics.add.collider(this.nextScene, this.platforms)
|
|
this.physics.add.collider(this.nextScene, this.platforms)
|
|
this.physics.add.overlap(this.nextScene, this.player1, this.handleLoadNextScene, undefined, this)
|
|
this.physics.add.overlap(this.nextScene, this.player1, this.handleLoadNextScene, undefined, this)
|
|
this.physics.add.overlap(this.nextScene, this.player2, this.handleLoadNextScene, undefined, this)
|
|
this.physics.add.overlap(this.nextScene, this.player2, this.handleLoadNextScene, undefined, this)
|
|
@@ -339,6 +344,13 @@ export default class HelloWorldScene extends Phaser.Scene {
|
|
//this.scene.start('ThreeScene')
|
|
//this.scene.start('ThreeScene')
|
|
//}
|
|
//}
|
|
|
|
|
|
|
|
+ //Test code related to buttons
|
|
|
|
+ private checkOverlap(button: Button, sprite: Phaser.Physics.Arcade.Sprite) {
|
|
|
|
+ var bounds_player = sprite.getBounds();
|
|
|
|
+ var bounds_button = button.getBounds();
|
|
|
|
+ return Phaser.Geom.Intersects.RectangleToRectangle(bounds_player, bounds_button);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
update() {
|
|
update() {
|
|
if (!this.cursors) {
|
|
if (!this.cursors) {
|
|
@@ -377,6 +389,17 @@ export default class HelloWorldScene extends Phaser.Scene {
|
|
if (this.cursors.up?.isDown && this.player2?.body.touching.down) {
|
|
if (this.cursors.up?.isDown && this.player2?.body.touching.down) {
|
|
this.player2.setVelocityY(-330)
|
|
this.player2.setVelocityY(-330)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ for(let i = 0; i < this.buttonArray.length; i++){
|
|
|
|
+ if(this.checkOverlap(this.buttonArray[i], this.player1) == false && this.checkOverlap(this.buttonArray[i], this.player2) == false){
|
|
|
|
+ let gateX = this.gateArray[this.buttonArray[i].gateID].x
|
|
|
|
+ let gateY = this.gateArray[this.buttonArray[i].gateID].y
|
|
|
|
+ this.gateArray[this.buttonArray[i].gateID].enableBody(false, gateX, gateY, true, true)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|