Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Nov 2, 2024
1 parent 81a1bb4 commit ece646e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/docs/bitmapzone.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Particles' emitter zone from canvas bitmap of text/canvas game object.

## Live demo

- [Particles](https://codepen.io/rexrainbow/pen/eYJmxwp)
- [Particles from text](https://codepen.io/rexrainbow/pen/eYJmxwp)
- [Particles from texture](https://codepen.io/rexrainbow/pen/qBeKXKw)

## Usage

Expand Down
4 changes: 0 additions & 4 deletions examples/bitmap-zone/particles.bat

This file was deleted.

4 changes: 4 additions & 0 deletions examples/bitmap-zone/text-particles.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set main=./examples/bitmap-zone/text-particles.js
cd ..
cd ..
npm run dev
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/bitmap-zone/texture-particles.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set main=./examples/bitmap-zone/texture-particles.js
cd ..
cd ..
npm run dev
69 changes: 69 additions & 0 deletions examples/bitmap-zone/texture-particles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import phaser from 'phaser/src/phaser.js';
import BitmapZonePlugin from '../../plugins/bitmapzone-plugin.js';
import CanvasPlugin from '../../plugins/canvas-plugin.js';

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

preload() {
this.load.atlas('flares', 'assets/images/particles/flares/flares.png', 'assets/images/particles/flares/flares.json');
this.load.image('money', 'assets/images/money.png');
}

create() {
var canvasObject = this.add.rexCanvas(400, 300)
.loadTexture('money')
.setScale(10)
.setVisible(false);

var canvasZone = this.plugins.get('rexBitmapZone').add(canvasObject);

var emitter = this.add.particles(400, 300, 'flares', {
blendMode: 'ADD',
scale: { start: 0.1, end: 0.2 },
quantity: 10,
advance: 1000,
speed: 8,
gravityY: -20,
emitZone: {
type: 'random',
source: canvasZone
}
})

}

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: 'rexBitmapZone',
plugin: BitmapZonePlugin,
start: true
},
{
key: 'rexCanvasPlugin',
plugin: CanvasPlugin,
start: true
},
]
}
};

var game = new Phaser.Game(config);

0 comments on commit ece646e

Please sign in to comment.