Skip to content

Commit

Permalink
Add test code
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Nov 25, 2023
1 parent f7fa36b commit 1bca2ad
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 5 deletions.
4 changes: 4 additions & 0 deletions examples/test/dropdown-shadow.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set main=./examples/test/dropdown-shadow.js
cd ..
cd ..
npm run watch
6 changes: 5 additions & 1 deletion examples/test/postfx.js → examples/test/dropdown-shadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Demo extends Phaser.Scene {

this.add.image(400, 300, 'classroom')

var gameObject = this.add.image(400, 300, 'mushroom')
// var gameObject = this.add.image(400, 300, 'mushroom')
var gameObject = this.add.line(400, 300, -50, 0, 50, 0, 0x00ff00).setLineWidth(10)
gameObject.moveTo = this.plugins.get('rexMoveTo').add(gameObject, {
speed: 400,
rotateToTarget: true
Expand All @@ -47,6 +48,9 @@ class Demo extends Phaser.Scene {
var touchY = pointer.y;
gameObject.moveTo.moveTo(touchX, touchY);
});


this.cameras.main.startFollow(gameObject);
}

update() {
Expand Down
4 changes: 4 additions & 0 deletions examples/test/outline.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set main=./examples/test/outline.js
cd ..
cd ..
npm run watch
82 changes: 82 additions & 0 deletions examples/test/outline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import phaser from 'phaser/src/phaser.js';
import OutlinePipelinePlugin from '../../plugins/outlinepipeline-plugin.js';
import MoveToPlugin from '../../plugins/moveto-plugin.js';


class Demo extends Phaser.Scene {
constructor() {
super({
key: 'examples'
})
}

preload() {
this.load.image('mushroom', 'assets/images/mushroom.png');
this.load.image('classroom', 'assets/images/backgrounds/classroom.png');
}

create() {
var postFxPlugin = this.plugins.get('rexOutlinePipeline');

this.add.image(400, 300, 'classroom')

var gameObject = this.add.image(400, 300, 'mushroom')
gameObject.moveTo = this.plugins.get('rexMoveTo').add(gameObject, {
speed: 400,
rotateToTarget: true
})
.on('start', function (dot, moveTo) {
if (postFxPlugin.get(gameObject)[0]) {
return;
}

postFxPlugin.add(gameObject, {
thickness: 5,
outlineColor: 0xff0000
});
})
.on('complete', function () {
postFxPlugin.remove(gameObject);
})

this.input.on('pointerdown', function (pointer) {
var touchX = pointer.x;
var touchY = pointer.y;
gameObject.moveTo.moveTo(touchX, touchY);
});


this.cameras.main.startFollow(gameObject);
}

update() {
}
}

var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
scene: Demo,
plugins: {
global: [
{
key: 'rexOutlinePipeline',
plugin: OutlinePipelinePlugin,
start: true
},
{
key: 'rexMoveTo',
plugin: MoveToPlugin,
start: true
}
]
}
};

var game = new Phaser.Game(config);
4 changes: 0 additions & 4 deletions examples/test/postfx.bat

This file was deleted.

4 changes: 4 additions & 0 deletions examples/test/shadow.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set main=./examples/test/shadow.js
cd ..
cd ..
npm run watch
63 changes: 63 additions & 0 deletions examples/test/shadow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import phaser from 'phaser/src/phaser.js';
import MoveToPlugin from '../../plugins/moveto-plugin.js';


class Demo extends Phaser.Scene {
constructor() {
super({
key: 'examples'
})
}

preload() {
this.load.image('mushroom', 'assets/images/mushroom.png');
this.load.image('classroom', 'assets/images/backgrounds/classroom.png');
}

create() {
this.add.image(400, 300, 'classroom')

var gameObject = this.add.image(400, 300, 'mushroom')
gameObject.postFX.addShadow(10, -10, 0.006, 1, 0xff0000, 10);

gameObject.moveTo = this.plugins.get('rexMoveTo').add(gameObject, {
tspeed: 400,
rotateToTarget: true
})

this.input.on('pointerdown', function (pointer) {
var touchX = pointer.x;
var touchY = pointer.y;
gameObject.moveTo.moveTo(touchX, touchY);
});


this.cameras.main.startFollow(gameObject);
}

update() {
}
}

var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
scene: Demo,
plugins: {
global: [
{
key: 'rexMoveTo',
plugin: MoveToPlugin,
start: true
}
]
}
};

var game = new Phaser.Game(config);

0 comments on commit 1bca2ad

Please sign in to comment.