mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +02:00
Fixup mock gameobject methods to match phaser gameobject returns
This commit is contained in:
parent
ec3a54273d
commit
1f14325ac7
@ -14,11 +14,12 @@ export class PlayerBattleInfo extends BattleInfo {
|
|||||||
expBar.setOrigin(0);
|
expBar.setOrigin(0);
|
||||||
this.add(expBar);
|
this.add(expBar);
|
||||||
|
|
||||||
const expMaskRect = globalScene.make.graphics({});
|
const expMaskRect = globalScene.make
|
||||||
expMaskRect.setScale(6);
|
.graphics({})
|
||||||
expMaskRect.fillStyle(0xffffff);
|
.setScale(6)
|
||||||
expMaskRect.beginPath();
|
.fillStyle(0xffffff)
|
||||||
expMaskRect.fillRect(127, 126, 85, 2);
|
.beginPath()
|
||||||
|
.fillRect(127, 126, 85, 2);
|
||||||
|
|
||||||
const expMask = expMaskRect.createGeometryMask();
|
const expMask = expMaskRect.createGeometryMask();
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export interface MockGameObject {
|
export interface MockGameObject {
|
||||||
name: string;
|
name: string;
|
||||||
|
destroy?(): void;
|
||||||
}
|
}
|
||||||
|
@ -2,199 +2,252 @@ import type MockTextureManager from "#test/testUtils/mocks/mockTextureManager";
|
|||||||
import type { MockGameObject } from "../mockGameObject";
|
import type { MockGameObject } from "../mockGameObject";
|
||||||
|
|
||||||
export default class MockContainer implements MockGameObject {
|
export default class MockContainer implements MockGameObject {
|
||||||
protected x;
|
protected x: number;
|
||||||
protected y;
|
protected y: number;
|
||||||
protected scene;
|
protected scene;
|
||||||
protected width;
|
protected width: number;
|
||||||
protected height;
|
protected height: number;
|
||||||
protected visible;
|
protected visible: boolean;
|
||||||
private alpha;
|
private alpha: number;
|
||||||
private style;
|
private style;
|
||||||
public frame;
|
public frame;
|
||||||
protected textureManager;
|
protected textureManager;
|
||||||
public list: MockGameObject[] = [];
|
public list: MockGameObject[] = [];
|
||||||
public name: string;
|
public name: string;
|
||||||
|
|
||||||
constructor(textureManager: MockTextureManager, x, y) {
|
constructor(textureManager: MockTextureManager, x: number, y: number) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.frame = {};
|
this.frame = {};
|
||||||
this.textureManager = textureManager;
|
this.textureManager = textureManager;
|
||||||
}
|
}
|
||||||
setVisible(visible) {
|
setVisible(visible: boolean): this {
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
once(_event, _callback, _source) {}
|
once(_event, _callback, _source): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
off(_event, _callback, _source) {}
|
off(_event, _callback, _source): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
removeFromDisplayList() {
|
removeFromDisplayList(): this {
|
||||||
// same as remove or destroy
|
// same as remove or destroy
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeBetween(_startIndex, _endIndex, _destroyChild) {
|
removeBetween(_startIndex, _endIndex, _destroyChild): this {
|
||||||
// Removes multiple children across an index range
|
// Removes multiple children across an index range
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addedToScene() {
|
addedToScene() {
|
||||||
// This callback is invoked when this Game Object is added to a Scene.
|
// This callback is invoked when this Game Object is added to a Scene.
|
||||||
}
|
}
|
||||||
|
|
||||||
setSize(_width, _height) {
|
setSize(_width: number, _height: number): this {
|
||||||
// Sets the size of this Game Object.
|
// Sets the size of this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setMask() {
|
setMask(): this {
|
||||||
/// Sets the mask that this Game Object will use to render with.
|
/// Sets the mask that this Game Object will use to render with.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPositionRelative(_source, _x, _y) {
|
setPositionRelative(_source, _x, _y) {
|
||||||
/// Sets the position of this Game Object to be a relative position from the source Game Object.
|
/// Sets the position of this Game Object to be a relative position from the source Game Object.
|
||||||
}
|
}
|
||||||
|
|
||||||
setInteractive = () => null;
|
setInteractive(): this {
|
||||||
|
return this;
|
||||||
setOrigin(x, y) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlpha(alpha) {
|
setOrigin(x = 0.5, y = x): this {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
setAlpha(alpha = 1): this {
|
||||||
this.alpha = alpha;
|
this.alpha = alpha;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFrame(_frame, _updateSize?: boolean, _updateOrigin?: boolean) {
|
setFrame(_frame, _updateSize?: boolean, _updateOrigin?: boolean): this {
|
||||||
// Sets the frame this Game Object will use to render with.
|
// Sets the frame this Game Object will use to render with.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setScale(_scale) {
|
setScale(_x = 1, _y = _x): this {
|
||||||
// Sets the scale of this Game Object.
|
// Sets the scale of this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(x, y) {
|
setPosition(x = 0, y = x, _z = 0, _w = 0): this {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setX(x) {
|
setX(x = 0): this {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setY(y) {
|
setY(y = 0): this {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
setShadow(_shadowXpos, _shadowYpos, _shadowColor) {
|
setShadow(_shadowXpos, _shadowYpos, _shadowColor): this {
|
||||||
// Sets the shadow settings for this Game Object.
|
// Sets the shadow settings for this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLineSpacing(_lineSpacing) {
|
setLineSpacing(_lineSpacing): this {
|
||||||
// Sets the line spacing value of this Game Object.
|
// Sets the line spacing value of this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setText(_text) {
|
setText(_text): this {
|
||||||
// Sets the text this Game Object will display.
|
// Sets the text this Game Object will display.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAngle(_angle) {
|
setAngle(_angle): this {
|
||||||
// Sets the angle of this Game Object.
|
// Sets the angle of this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setShadowOffset(_offsetX, _offsetY) {
|
setShadowOffset(_offsetX, _offsetY): this {
|
||||||
// Sets the shadow offset values.
|
// Sets the shadow offset values.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setWordWrapWidth(_width) {
|
setWordWrapWidth(_width) {
|
||||||
// Sets the width (in pixels) to use for wrapping lines.
|
// Sets the width (in pixels) to use for wrapping lines.
|
||||||
}
|
}
|
||||||
|
|
||||||
setFontSize(_fontSize) {
|
setFontSize(_fontSize): this {
|
||||||
// Sets the font size of this Game Object.
|
// Sets the font size of this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
getBounds() {
|
getBounds() {
|
||||||
return { width: this.width, height: this.height };
|
return { width: this.width, height: this.height };
|
||||||
}
|
}
|
||||||
|
|
||||||
setColor(_color) {
|
setColor(_color): this {
|
||||||
// Sets the tint of this Game Object.
|
// Sets the tint of this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setShadowColor(_color) {
|
setShadowColor(_color): this {
|
||||||
// Sets the shadow color.
|
// Sets the shadow color.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTint(_color) {
|
setTint(_color: this) {
|
||||||
// Sets the tint of this Game Object.
|
// Sets the tint of this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStrokeStyle(_thickness, _color) {
|
setStrokeStyle(_thickness, _color): this {
|
||||||
// Sets the stroke style for the graphics.
|
// Sets the stroke style for the graphics.
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setDepth(_depth) {
|
setDepth(_depth): this {
|
||||||
// Sets the depth of this Game Object.
|
// Sets the depth of this Game Object.\
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTexture(_texture) {
|
setTexture(_texture): this {
|
||||||
// Sets the texture this Game Object will use to render with.
|
// Sets the texture this Game Object will use to render with.\
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTint() {
|
clearTint(): this {
|
||||||
// Clears any previously set tint.
|
// Clears any previously set tint.\
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToBack() {
|
sendToBack(): this {
|
||||||
// Sends this Game Object to the back of its parent's display list.
|
// Sends this Game Object to the back of its parent's display list.\
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveTo(_obj) {
|
moveTo(_obj): this {
|
||||||
// Moves this Game Object to the given index in the list.
|
// Moves this Game Object to the given index in the list.\
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveAbove(_obj) {
|
moveAbove(_obj): this {
|
||||||
// Moves this Game Object to be above the given Game Object in the display list.
|
// Moves this Game Object to be above the given Game Object in the display list.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveBelow(_obj) {
|
moveBelow(_obj): this {
|
||||||
// Moves this Game Object to be below the given Game Object in the display list.
|
// Moves this Game Object to be below the given Game Object in the display list.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setName(name: string) {
|
setName(name: string): this {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bringToTop(_obj) {
|
bringToTop(_obj): this {
|
||||||
// Brings this Game Object to the top of its parents display list.
|
// Brings this Game Object to the top of its parents display list.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
on(_event, _callback, _source) {}
|
on(_event, _callback, _source): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
add(obj) {
|
add(...obj: MockGameObject[]): this {
|
||||||
// Adds a child to this Game Object.
|
// Adds a child to this Game Object.
|
||||||
this.list.push(obj);
|
this.list.push(...obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAll() {
|
removeAll(): this {
|
||||||
// Removes all Game Objects from this Container.
|
// Removes all Game Objects from this Container.
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addAt(obj, index) {
|
addAt(obj: MockGameObject | MockGameObject[], index = 0): this {
|
||||||
// Adds a Game Object to this Container at the given index.
|
// Adds a Game Object to this Container at the given index.
|
||||||
this.list.splice(index, 0, obj);
|
if (!Array.isArray(obj)) {
|
||||||
|
obj = [obj];
|
||||||
|
}
|
||||||
|
this.list.splice(index, 0, ...obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(obj) {
|
remove(obj: MockGameObject | MockGameObject[], destroyChild = false): this {
|
||||||
const index = this.list.indexOf(obj);
|
if (!Array.isArray(obj)) {
|
||||||
|
obj = [obj];
|
||||||
|
}
|
||||||
|
for (const item of obj) {
|
||||||
|
const index = this.list.indexOf(item);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.list.splice(index, 1);
|
this.list.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
if (destroyChild) {
|
||||||
|
item.destroy?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndex(obj) {
|
getIndex(obj) {
|
||||||
@ -210,15 +263,28 @@ export default class MockContainer implements MockGameObject {
|
|||||||
return this.list;
|
return this.list;
|
||||||
}
|
}
|
||||||
|
|
||||||
getByName(key: string) {
|
getByName(key: string): MockGameObject | null {
|
||||||
return this.list.find(v => v.name === key) ?? new MockContainer(this.textureManager, 0, 0);
|
return this.list.find(v => v.name === key) ?? new MockContainer(this.textureManager, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
disableInteractive = () => null;
|
disableInteractive(): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
each(method) {
|
each(method): this {
|
||||||
for (const item of this.list) {
|
for (const item of this.list) {
|
||||||
method(item);
|
method(item);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
copyPosition(source: { x?: number; y?: number }): this {
|
||||||
|
if (source.x !== undefined) {
|
||||||
|
this.x = source.x;
|
||||||
|
}
|
||||||
|
if (source.y !== undefined) {
|
||||||
|
this.y = source.y;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,34 +8,49 @@ export default class MockGraphics implements MockGameObject {
|
|||||||
this.scene = textureManager.scene;
|
this.scene = textureManager.scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
fillStyle(_color) {
|
fillStyle(_color): this {
|
||||||
// Sets the fill style to be used by the fill methods.
|
// Sets the fill style to be used by the fill methods.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
beginPath() {
|
beginPath(): this {
|
||||||
// Starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path.
|
// Starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
fillRect(_x, _y, _width, _height) {
|
fillRect(_x, _y, _width, _height): this {
|
||||||
// Adds a rectangle shape to the path which is filled when you call fill().
|
// Adds a rectangle shape to the path which is filled when you call fill().
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
createGeometryMask() {
|
createGeometryMask(): this {
|
||||||
// Creates a geometry mask.
|
// Creates a geometry mask.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setOrigin(_x, _y) {}
|
setOrigin(_x, _y): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setAlpha(_alpha) {}
|
setAlpha(_alpha): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setVisible(_visible) {}
|
setVisible(_visible): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setName(_name) {}
|
setName(_name) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
once(_event, _callback, _source) {}
|
once(_event, _callback, _source) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
removeFromDisplayList() {
|
removeFromDisplayList(): this {
|
||||||
// same as remove or destroy
|
// same as remove or destroy
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addedToScene() {
|
addedToScene() {
|
||||||
@ -50,15 +65,18 @@ export default class MockGraphics implements MockGameObject {
|
|||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
setScale(_scale) {
|
setScale(_scale): this {
|
||||||
// Sets the scale of this Game Object.
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
off(_event, _callback, _source) {}
|
off(_event, _callback, _source): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
add(obj) {
|
add(obj): this {
|
||||||
// Adds a child to this Game Object.
|
// Adds a child to this Game Object.
|
||||||
this.list.push(obj);
|
this.list.push(obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAll() {
|
removeAll() {
|
||||||
@ -90,4 +108,8 @@ export default class MockGraphics implements MockGameObject {
|
|||||||
getAll() {
|
getAll() {
|
||||||
return this.list;
|
return this.list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyPosition(_source): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,17 +10,28 @@ export default class MockRectangle implements MockGameObject {
|
|||||||
this.fillColor = fillColor;
|
this.fillColor = fillColor;
|
||||||
this.scene = textureManager.scene;
|
this.scene = textureManager.scene;
|
||||||
}
|
}
|
||||||
setOrigin(_x, _y) {}
|
setOrigin(_x, _y): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setAlpha(_alpha) {}
|
setAlpha(_alpha): this {
|
||||||
setVisible(_visible) {}
|
return this;
|
||||||
|
}
|
||||||
|
setVisible(_visible): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setName(_name) {}
|
setName(_name): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
once(_event, _callback, _source) {}
|
once(_event, _callback, _source): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
removeFromDisplayList() {
|
removeFromDisplayList(): this {
|
||||||
// same as remove or destroy
|
// same as remove or destroy
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addedToScene() {
|
addedToScene() {
|
||||||
@ -35,9 +46,10 @@ export default class MockRectangle implements MockGameObject {
|
|||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
add(obj) {
|
add(obj): this {
|
||||||
// Adds a child to this Game Object.
|
// Adds a child to this Game Object.
|
||||||
this.list.push(obj);
|
this.list.push(obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAll() {
|
removeAll() {
|
||||||
@ -45,16 +57,18 @@ export default class MockRectangle implements MockGameObject {
|
|||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
addAt(obj, index) {
|
addAt(obj, index): this {
|
||||||
// Adds a Game Object to this Container at the given index.
|
// Adds a Game Object to this Container at the given index.
|
||||||
this.list.splice(index, 0, obj);
|
this.list.splice(index, 0, obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(obj) {
|
remove(obj): this {
|
||||||
const index = this.list.indexOf(obj);
|
const index = this.list.indexOf(obj);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.list.splice(index, 1);
|
this.list.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndex(obj) {
|
getIndex(obj) {
|
||||||
@ -69,9 +83,12 @@ export default class MockRectangle implements MockGameObject {
|
|||||||
getAll() {
|
getAll() {
|
||||||
return this.list;
|
return this.list;
|
||||||
}
|
}
|
||||||
setScale(_scale) {
|
setScale(_scale): this {
|
||||||
// return this.phaserText.setScale(scale);
|
// return this.phaserText.setScale(scale);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
off() {}
|
off(): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ export default class MockSprite implements MockGameObject {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
Phaser.GameObjects.Sprite.prototype.setTexture = this.setTexture;
|
Phaser.GameObjects.Sprite.prototype.setTexture = this.setTexture;
|
||||||
Phaser.GameObjects.Sprite.prototype.setSizeToFrame = this.setSizeToFrame;
|
Phaser.GameObjects.Sprite.prototype.setSizeToFrame = this.setSizeToFrame;
|
||||||
|
// @ts-ignore
|
||||||
Phaser.GameObjects.Sprite.prototype.setFrame = this.setFrame;
|
Phaser.GameObjects.Sprite.prototype.setFrame = this.setFrame;
|
||||||
// Phaser.GameObjects.Sprite.prototype.disable = this.disable;
|
// Phaser.GameObjects.Sprite.prototype.disable = this.disable;
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ export default class MockSprite implements MockGameObject {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setTexture(_key: string, _frame?: string | number) {
|
setTexture(_key: string, _frame?: string | number): this {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,38 +46,47 @@ export default class MockSprite implements MockGameObject {
|
|||||||
return {} as Sprite;
|
return {} as Sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPipeline(obj) {
|
setPipeline(obj): this {
|
||||||
// Sets the pipeline of this Game Object.
|
// Sets the pipeline of this Game Object.
|
||||||
return this.phaserSprite.setPipeline(obj);
|
this.phaserSprite.setPipeline(obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
off(_event, _callback, _source) {}
|
off(_event, _callback, _source): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setTintFill(color) {
|
setTintFill(color): this {
|
||||||
// Sets the tint fill color.
|
// Sets the tint fill color.
|
||||||
return this.phaserSprite.setTintFill(color);
|
this.phaserSprite.setTintFill(color);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setScale(scale) {
|
setScale(scale): this {
|
||||||
return this.phaserSprite.setScale(scale);
|
this.phaserSprite.setScale(scale);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setOrigin(x, y) {
|
setOrigin(x, y): this {
|
||||||
return this.phaserSprite.setOrigin(x, y);
|
this.phaserSprite.setOrigin(x, y);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSize(width, height) {
|
setSize(width, height): this {
|
||||||
// Sets the size of this Game Object.
|
// Sets the size of this Game Object.
|
||||||
return this.phaserSprite.setSize(width, height);
|
this.phaserSprite.setSize(width, height);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
once(event, callback, source) {
|
once(event, callback, source): this {
|
||||||
return this.phaserSprite.once(event, callback, source);
|
this.phaserSprite.once(event, callback, source);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFromDisplayList() {
|
removeFromDisplayList(): this {
|
||||||
// same as remove or destroy
|
// same as remove or destroy
|
||||||
return this.phaserSprite.removeFromDisplayList();
|
this.phaserSprite.removeFromDisplayList();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addedToScene() {
|
addedToScene() {
|
||||||
@ -84,97 +94,116 @@ export default class MockSprite implements MockGameObject {
|
|||||||
return this.phaserSprite.addedToScene();
|
return this.phaserSprite.addedToScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisible(visible) {
|
setVisible(visible): this {
|
||||||
return this.phaserSprite.setVisible(visible);
|
this.phaserSprite.setVisible(visible);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(x, y) {
|
setPosition(x, y): this {
|
||||||
return this.phaserSprite.setPosition(x, y);
|
this.phaserSprite.setPosition(x, y);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setRotation(radians) {
|
setRotation(radians): this {
|
||||||
return this.phaserSprite.setRotation(radians);
|
this.phaserSprite.setRotation(radians);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop(): this {
|
||||||
return this.phaserSprite.stop();
|
this.phaserSprite.stop();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInteractive = () => null;
|
setInteractive(): this {
|
||||||
|
return this;
|
||||||
on(event, callback, source) {
|
|
||||||
return this.phaserSprite.on(event, callback, source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlpha(alpha) {
|
on(event, callback, source): this {
|
||||||
return this.phaserSprite.setAlpha(alpha);
|
this.phaserSprite.on(event, callback, source);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTint(color) {
|
setAlpha(alpha): this {
|
||||||
|
this.phaserSprite.setAlpha(alpha);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTint(color): this {
|
||||||
// Sets the tint of this Game Object.
|
// Sets the tint of this Game Object.
|
||||||
return this.phaserSprite.setTint(color);
|
this.phaserSprite.setTint(color);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFrame(frame, _updateSize?: boolean, _updateOrigin?: boolean) {
|
setFrame(frame, _updateSize?: boolean, _updateOrigin?: boolean): this {
|
||||||
// Sets the frame this Game Object will use to render with.
|
// Sets the frame this Game Object will use to render with.
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
return frame;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPositionRelative(source, x, y) {
|
setPositionRelative(source, x, y) {
|
||||||
/// Sets the position of this Game Object to be a relative position from the source Game Object.
|
/// Sets the position of this Game Object to be a relative position from the source Game Object.
|
||||||
return this.phaserSprite.setPositionRelative(source, x, y);
|
this.phaserSprite.setPositionRelative(source, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
setY(y) {
|
setY(y: number): this {
|
||||||
return this.phaserSprite.setY(y);
|
this.phaserSprite.setY(y);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCrop(x, y, width, height) {
|
setCrop(x: number, y: number, width: number, height: number): this {
|
||||||
// Sets the crop size of this Game Object.
|
// Sets the crop size of this Game Object.
|
||||||
return this.phaserSprite.setCrop(x, y, width, height);
|
this.phaserSprite.setCrop(x, y, width, height);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTint() {
|
clearTint(): this {
|
||||||
// Clears any previously set tint.
|
// Clears any previously set tint.
|
||||||
return this.phaserSprite.clearTint();
|
this.phaserSprite.clearTint();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
disableInteractive() {
|
disableInteractive(): this {
|
||||||
// Disables Interactive features of this Game Object.
|
// Disables Interactive features of this Game Object.
|
||||||
return null;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply() {
|
apply() {
|
||||||
return this.phaserSprite.apply();
|
this.phaserSprite.apply();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
play() {
|
play(): this {
|
||||||
// return this.phaserSprite.play();
|
// return this.phaserSprite.play();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPipelineData(key, value) {
|
setPipelineData(key: string, value: any): this {
|
||||||
this.pipelineData[key] = value;
|
this.pipelineData[key] = value;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
return this.phaserSprite.destroy();
|
return this.phaserSprite.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
setName(name) {
|
setName(name: string): this {
|
||||||
return this.phaserSprite.setName(name);
|
this.phaserSprite.setName(name);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAngle(angle) {
|
setAngle(angle): this {
|
||||||
return this.phaserSprite.setAngle(angle);
|
this.phaserSprite.setAngle(angle);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setMask() {}
|
setMask(): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
add(obj) {
|
add(obj): this {
|
||||||
// Adds a child to this Game Object.
|
// Adds a child to this Game Object.
|
||||||
this.list.push(obj);
|
this.list.push(obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAll() {
|
removeAll() {
|
||||||
@ -182,16 +211,18 @@ export default class MockSprite implements MockGameObject {
|
|||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
addAt(obj, index) {
|
addAt(obj, index): this {
|
||||||
// Adds a Game Object to this Container at the given index.
|
// Adds a Game Object to this Container at the given index.
|
||||||
this.list.splice(index, 0, obj);
|
this.list.splice(index, 0, obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(obj) {
|
remove(obj): this {
|
||||||
const index = this.list.indexOf(obj);
|
const index = this.list.indexOf(obj);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.list.splice(index, 1);
|
this.list.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndex(obj) {
|
getIndex(obj) {
|
||||||
@ -206,4 +237,9 @@ export default class MockSprite implements MockGameObject {
|
|||||||
getAll() {
|
getAll() {
|
||||||
return this.list;
|
return this.list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyPosition(obj): this {
|
||||||
|
this.phaserSprite.copyPosition(obj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,42 +107,51 @@ export default class MockText implements MockGameObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setScale(_scale) {
|
setScale(_scale): this {
|
||||||
// return this.phaserText.setScale(scale);
|
// return this.phaserText.setScale(scale);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setShadow(_shadowXpos, _shadowYpos, _shadowColor) {
|
setShadow(_shadowXpos, _shadowYpos, _shadowColor): this {
|
||||||
// Sets the shadow settings for this Game Object.
|
// Sets the shadow settings for this Game Object.
|
||||||
// return this.phaserText.setShadow(shadowXpos, shadowYpos, shadowColor);
|
// return this.phaserText.setShadow(shadowXpos, shadowYpos, shadowColor);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLineSpacing(_lineSpacing) {
|
setLineSpacing(_lineSpacing): this {
|
||||||
// Sets the line spacing value of this Game Object.
|
// Sets the line spacing value of this Game Object.
|
||||||
// return this.phaserText.setLineSpacing(lineSpacing);
|
// return this.phaserText.setLineSpacing(lineSpacing);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setOrigin(_x, _y) {
|
setOrigin(_x, _y): this {
|
||||||
// return this.phaserText.setOrigin(x, y);
|
// return this.phaserText.setOrigin(x, y);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
once(_event, _callback, _source) {
|
once(_event, _callback, _source): this {
|
||||||
// return this.phaserText.once(event, callback, source);
|
// return this.phaserText.once(event, callback, source);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
off(_event, _callback, _obj) {}
|
off(_event, _callback, _obj) {}
|
||||||
|
|
||||||
removedFromScene() {}
|
removedFromScene() {}
|
||||||
|
|
||||||
addToDisplayList() {}
|
addToDisplayList(): this {
|
||||||
|
return this;
|
||||||
setStroke(_color, _thickness) {
|
|
||||||
// Sets the stroke color and thickness.
|
|
||||||
// return this.phaserText.setStroke(color, thickness);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFromDisplayList() {
|
setStroke(_color, _thickness): this {
|
||||||
|
// Sets the stroke color and thickness.
|
||||||
|
// return this.phaserText.setStroke(color, thickness);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFromDisplayList(): this {
|
||||||
// same as remove or destroy
|
// same as remove or destroy
|
||||||
// return this.phaserText.removeFromDisplayList();
|
// return this.phaserText.removeFromDisplayList();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addedToScene() {
|
addedToScene() {
|
||||||
@ -154,12 +163,14 @@ export default class MockText implements MockGameObject {
|
|||||||
// return this.phaserText.setVisible(visible);
|
// return this.phaserText.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
setY(_y) {
|
setY(_y): this {
|
||||||
// return this.phaserText.setY(y);
|
// return this.phaserText.setY(y);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setX(_x) {
|
setX(_x): this {
|
||||||
// return this.phaserText.setX(x);
|
// return this.phaserText.setX(x);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,17 +180,21 @@ export default class MockText implements MockGameObject {
|
|||||||
* @param z The z position of this Game Object. Default 0.
|
* @param z The z position of this Game Object. Default 0.
|
||||||
* @param w The w position of this Game Object. Default 0.
|
* @param w The w position of this Game Object. Default 0.
|
||||||
*/
|
*/
|
||||||
setPosition(_x?: number, _y?: number, _z?: number, _w?: number) {}
|
setPosition(_x?: number, _y?: number, _z?: number, _w?: number): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setText(text) {
|
setText(text): this {
|
||||||
// Sets the text this Game Object will display.
|
// Sets the text this Game Object will display.
|
||||||
// return this.phaserText.setText\(text);
|
// return this.phaserText.setText\(text);
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAngle(_angle) {
|
setAngle(_angle): this {
|
||||||
// Sets the angle of this Game Object.
|
// Sets the angle of this Game Object.
|
||||||
// return this.phaserText.setAngle(angle);
|
// return this.phaserText.setAngle(angle);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPositionRelative(_source, _x, _y) {
|
setPositionRelative(_source, _x, _y) {
|
||||||
@ -187,9 +202,10 @@ export default class MockText implements MockGameObject {
|
|||||||
// return this.phaserText.setPositionRelative(source, x, y);
|
// return this.phaserText.setPositionRelative(source, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
setShadowOffset(_offsetX, _offsetY) {
|
setShadowOffset(_offsetX, _offsetY): this {
|
||||||
// Sets the shadow offset values.
|
// Sets the shadow offset values.
|
||||||
// return this.phaserText.setShadowOffset(offsetX, offsetY);
|
// return this.phaserText.setShadowOffset(offsetX, offsetY);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setWordWrapWidth(width) {
|
setWordWrapWidth(width) {
|
||||||
@ -197,9 +213,10 @@ export default class MockText implements MockGameObject {
|
|||||||
this.wordWrapWidth = width;
|
this.wordWrapWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFontSize(_fontSize) {
|
setFontSize(_fontSize): this {
|
||||||
// Sets the font size of this Game Object.
|
// Sets the font size of this Game Object.
|
||||||
// return this.phaserText.setFontSize(fontSize);
|
// return this.phaserText.setFontSize(fontSize);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBounds() {
|
getBounds() {
|
||||||
@ -209,25 +226,31 @@ export default class MockText implements MockGameObject {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setColor(color: string) {
|
setColor(color: string): this {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInteractive = () => null;
|
setInteractive(): this {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
setShadowColor(_color) {
|
setShadowColor(_color): this {
|
||||||
// Sets the shadow color.
|
// Sets the shadow color.
|
||||||
// return this.phaserText.setShadowColor(color);
|
// return this.phaserText.setShadowColor(color);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTint(_color) {
|
setTint(_color): this {
|
||||||
// Sets the tint of this Game Object.
|
// Sets the tint of this Game Object.
|
||||||
// return this.phaserText.setTint(color);
|
// return this.phaserText.setTint(color);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStrokeStyle(_thickness, _color) {
|
setStrokeStyle(_thickness, _color): this {
|
||||||
// Sets the stroke style for the graphics.
|
// Sets the stroke style for the graphics.
|
||||||
// return this.phaserText.setStrokeStyle(thickness, color);
|
// return this.phaserText.setStrokeStyle(thickness, color);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
@ -235,20 +258,24 @@ export default class MockText implements MockGameObject {
|
|||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlpha(_alpha) {
|
setAlpha(_alpha): this {
|
||||||
// return this.phaserText.setAlpha(alpha);
|
// return this.phaserText.setAlpha(alpha);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setName(name: string) {
|
setName(name: string): this {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlign(_align) {
|
setAlign(_align): this {
|
||||||
// return this.phaserText.setAlign(align);
|
// return this.phaserText.setAlign(align);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setMask() {
|
setMask(): this {
|
||||||
/// Sets the mask that this Game Object will use to render with.
|
/// Sets the mask that this Game Object will use to render with.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBottomLeft() {
|
getBottomLeft() {
|
||||||
@ -265,37 +292,43 @@ export default class MockText implements MockGameObject {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
disableInteractive() {
|
disableInteractive(): this {
|
||||||
// Disables interaction with this Game Object.
|
// Disables interaction with this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTint() {
|
clearTint(): this {
|
||||||
// Clears tint on this Game Object.
|
// Clears tint on this Game Object.
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(obj) {
|
add(obj): this {
|
||||||
// Adds a child to this Game Object.
|
// Adds a child to this Game Object.
|
||||||
this.list.push(obj);
|
this.list.push(obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAll() {
|
removeAll(): this {
|
||||||
// Removes all Game Objects from this Container.
|
// Removes all Game Objects from this Container.
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addAt(obj, index) {
|
addAt(obj, index): this {
|
||||||
// Adds a Game Object to this Container at the given index.
|
// Adds a Game Object to this Container at the given index.
|
||||||
this.list.splice(index, 0, obj);
|
this.list.splice(index, 0, obj);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(obj) {
|
remove(obj): this {
|
||||||
const index = this.list.indexOf(obj);
|
const index = this.list.indexOf(obj);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.list.splice(index, 1);
|
this.list.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndex(obj) {
|
getIndex(obj): number {
|
||||||
const index = this.list.indexOf(obj);
|
const index = this.list.indexOf(obj);
|
||||||
return index || -1;
|
return index || -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user