-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RoundRectangleProgress game object
- Loading branch information
1 parent
df2882c
commit f88a028
Showing
27 changed files
with
1,138 additions
and
43 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,4 @@ | ||
set main=./examples/roundrectangleprogress/roundrectangleprogress.js | ||
cd .. | ||
cd .. | ||
npm run watch |
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,94 @@ | ||
import phaser from 'phaser/src/phaser.js'; | ||
import RoundrRctangleProgressPlugin from '../../plugins/roundrectangleprogress-plugin.js'; | ||
import Dat from '../../plugins/utils/dat.gui/dat.gui.min.js'; | ||
|
||
const COLOR_MAIN = 0x4e342e; | ||
const COLOR_LIGHT = 0x7b5e57; | ||
const COLOR_DARK = 0x260e04; | ||
|
||
class Demo extends Phaser.Scene { | ||
constructor() { | ||
super({ | ||
key: 'examples' | ||
}) | ||
} | ||
|
||
preload() { } | ||
|
||
create() { | ||
//var radius = 30; | ||
var radius = { tl: 0, tr: 0, bl: 30, br: 30 }; | ||
|
||
var bar0 = this.add.rexRoundRectangleProgress({ | ||
x: 200, y: 150, | ||
width: 200, height: 90, | ||
radius: radius, | ||
barColor: COLOR_MAIN, | ||
trackColor: COLOR_DARK, | ||
trackStrokeColor: COLOR_LIGHT, | ||
value: 0.5 | ||
}) | ||
|
||
var bar1 = this.add.rexRoundRectangleProgress({ | ||
x: 500, y: 150, | ||
width: 200, height: 90, | ||
radius: radius, | ||
rtl: true, | ||
barColor: COLOR_MAIN, | ||
trackColor: COLOR_DARK, | ||
trackStrokeColor: COLOR_LIGHT, | ||
value: 0.5 | ||
}) | ||
|
||
var bar2 = this.add.rexRoundRectangleProgress({ | ||
x: 200, y: 400, | ||
width: 90, height: 200, | ||
radius: radius, | ||
orientation: 1, | ||
barColor: COLOR_MAIN, | ||
trackColor: COLOR_DARK, | ||
trackStrokeColor: COLOR_LIGHT, | ||
value: 0.5 | ||
}) | ||
|
||
var bar3 = this.add.rexRoundRectangleProgress({ | ||
x: 500, y: 400, | ||
width: 90, height: 200, | ||
radius: radius, | ||
rtl: true, orientation: 1, | ||
barColor: COLOR_MAIN, | ||
trackColor: COLOR_DARK, | ||
trackStrokeColor: COLOR_LIGHT, | ||
value: 0.5 | ||
}) | ||
|
||
var gui = new Dat.GUI(); | ||
gui.add(bar0, 'value', 0, 1); | ||
gui.add(bar1, 'value', 0, 1); | ||
gui.add(bar2, 'value', 0, 1); | ||
gui.add(bar3, 'value', 0, 1); | ||
} | ||
|
||
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: 'rexRoundrRctangleProgress', | ||
plugin: RoundrRctangleProgressPlugin, | ||
start: true | ||
}] | ||
} | ||
}; | ||
|
||
var game = new Phaser.Game(config); |
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
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
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
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
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
12 changes: 12 additions & 0 deletions
12
plugins/gameobjects/shape/roundrectangleprogress/Creator.d.ts
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,12 @@ | ||
import RoundRectangleProgress from './RoundRectangleProgress'; | ||
|
||
export default Creator; | ||
|
||
declare namespace Creator { | ||
interface IConfig extends Phaser.Types.GameObjects.GameObjectConfig { } | ||
} | ||
|
||
declare function Creator( | ||
config?: Creator.IConfig, | ||
addToScene?: boolean, | ||
): RoundRectangleProgress; |
13 changes: 13 additions & 0 deletions
13
plugins/gameobjects/shape/roundrectangleprogress/Creator.js
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,13 @@ | ||
import RoundRectangleProgress from './RoundRectangleProgress.js'; | ||
|
||
const BuildGameObject = Phaser.GameObjects.BuildGameObject; | ||
|
||
export default function (config, addToScene) { | ||
if (config === undefined) { config = {}; } | ||
if (addToScene !== undefined) { | ||
config.add = addToScene; | ||
} | ||
var gameObject = new RoundRectangleProgress(this.scene, config); | ||
BuildGameObject(this.scene, gameObject, config); | ||
return gameObject; | ||
}; |
19 changes: 19 additions & 0 deletions
19
plugins/gameobjects/shape/roundrectangleprogress/Factory.d.ts
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,19 @@ | ||
import RoundRectangleProgress from './RoundRectangleProgress'; | ||
|
||
export default function ( | ||
config?: RoundRectangleProgress.IConfig | ||
): RoundRectangleProgress; | ||
|
||
export default function ( | ||
x?: number, y?: number, | ||
width?: number, height?: number, | ||
config?: RoundRectangleProgress.IConfig | ||
): RoundRectangleProgress; | ||
|
||
export default function ( | ||
x?: number, y?: number, | ||
width?: number, height?: number, | ||
barColor?: string | number, | ||
value?: number, | ||
config?: RoundRectangleProgress.IConfig | ||
): RoundRectangleProgress; |
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 @@ | ||
import RoundRectangleProgress from './RoundRectangleProgress.js'; | ||
|
||
export default function (x, y, width, height, barColor, value, config) { | ||
var gameObject = new RoundRectangleProgress(this.scene, x, y, width, height, barColor, value, config); | ||
this.scene.add.existing(gameObject); | ||
return gameObject; | ||
}; |
Oops, something went wrong.