diff --git a/dist/animator.d.ts.map b/dist/animator.d.ts.map
index 555506e..f4dc555 100644
--- a/dist/animator.d.ts.map
+++ b/dist/animator.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../src/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAa,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,QAAS,SAAQ,IAAI,CAAC,SAAU,YAAW,cAAc;IACpE;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAiB;IAElD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAiB;IAEjD;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAiB;IAEpD;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IAEhC;;OAEG;IACH,UAAU,EAAE,eAAe,CAAC;IAE5B;;OAEG;IACH,KAAK,SAAc;IAEnB;;OAEG;IACH,MAAM,EAAE,MAAM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C,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAMxC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;IAqBjE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,UAAO,EAAE,iBAAiB,SAAS,GAAG,MAAM;IA6BxE,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAInD,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAcpD"}
\ No newline at end of file
diff --git a/dist/animator.js b/dist/animator.js
index 5e819f9..8d60012 100644
--- a/dist/animator.js
+++ b/dist/animator.js
@@ -35,7 +35,6 @@ class Animator extends PIXI.Container {
* @param texture
*/
constructor(gameObject, { animations, cols, rows, animationSpeed = 16.67, anchor = { x: 0.5, y: 0.5 } }, { width, height, source }) {
- var _a;
super();
/**
* When Lifecycle Object is updated, it emits this subject.
@@ -57,7 +56,6 @@ class Animator extends PIXI.Container {
this.label = 'Animator';
gameObject.addChild(this);
this.stateMachine = new state_machine_1.StateMachine(gameObject);
- this.sprite = new PIXI.Container();
const tileWidth = width / cols;
const tileHeight = height / rows;
Object.values(animations).forEach((animationFrames) => {
@@ -69,10 +67,9 @@ class Animator extends PIXI.Container {
return { texture, time: animationSpeed };
}));
animatedSprite.anchor.set(anchor.x, anchor.y);
- this.sprite.addChild(animatedSprite);
+ this.addChild(animatedSprite);
});
this.states = Object.keys(animations);
- (_a = gameObject.scene) === null || _a === void 0 ? void 0 : _a.stage.addChild(this.sprite);
}
/**
* Reference to inner State Machine's state.
@@ -93,12 +90,12 @@ class Animator extends PIXI.Container {
return this.animation.scale;
}
update(deltaTime) {
- this.sprite.x = this.gameObject.x;
- this.sprite.y = this.gameObject.y;
+ this.x = this.gameObject.x;
+ this.y = this.gameObject.y;
lifecycle_1.Lifecycle.update(this, deltaTime);
}
setScale(x = 1, y = x) {
- this.sprite.children.forEach((child) => {
+ this.children.forEach((child) => {
child.scale.set(x, y);
});
}
@@ -110,7 +107,7 @@ class Animator extends PIXI.Container {
if (animation === this.animation) {
return;
}
- const children = this.sprite.children.filter((child) => child instanceof PIXI.AnimatedSprite && child !== animation);
+ const children = this.children.filter((child) => child instanceof PIXI.AnimatedSprite && child !== animation);
children.forEach((child) => {
child.visible = false;
child.stop();
@@ -132,7 +129,7 @@ class Animator extends PIXI.Container {
if (!this.stateMachine.setState(next)) {
return '';
}
- const animation = this.sprite.children[index];
+ const animation = this.children[index];
if (!loop && stateWhenFinished) {
animation.onComplete = () => {
animation.onComplete = null;
diff --git a/docs/classes/Animator.html b/docs/classes/Animator.html
index 2c62dee..a0ca559 100644
--- a/docs/classes/Animator.html
+++ b/docs/classes/Animator.html
@@ -95,8 +95,8 @@
Implements
Defined in
src/animator.ts:18src/animator.ts:17
@@ -1433,8 +1433,8 @@
Defined in
src/animator.ts:71src/animator.ts:70
@@ -2091,8 +2091,8 @@
Defined in
src/animator.ts:64src/animator.ts:63
@@ -2206,8 +2206,8 @@
Defined in
src/animator.ts:34src/animator.ts:33
@@ -2475,8 +2475,8 @@
Defined in
src/animator.ts:29src/animator.ts:28
@@ -2738,8 +2738,8 @@
Defined in
src/animator.ts:49src/animator.ts:48
@@ -3134,8 +3134,8 @@
Defined in
src/animator.ts:54src/animator.ts:53
@@ -4971,8 +4971,8 @@
Defined in
src/animator.ts:44src/animator.ts:43
@@ -5009,8 +5009,8 @@
Defined in
src/animator.ts:39src/animator.ts:38
@@ -5040,8 +5040,8 @@
Defined in
src/animator.ts:59src/animator.ts:58
@@ -5148,8 +5148,8 @@
Defined in
src/animator.ts:23src/animator.ts:22
@@ -6020,8 +6020,8 @@
Defined in
src/animator.ts:134src/animator.ts:129
@@ -6138,8 +6138,8 @@
Defined in
src/animator.ts:120src/animator.ts:115
@@ -6184,8 +6184,8 @@
Defined in
src/animator.ts:127src/animator.ts:122
@@ -7907,8 +7907,8 @@
Defined in
src/animator.ts:152src/animator.ts:147
@@ -8443,8 +8443,8 @@
Defined in
src/animator.ts:208src/animator.ts:203
@@ -8506,8 +8506,8 @@
Defined in
src/animator.ts:212src/animator.ts:207
@@ -10432,8 +10432,8 @@
Defined in
src/animator.ts:158src/animator.ts:153
@@ -10636,8 +10636,8 @@
Defined in
src/animator.ts:144src/animator.ts:139
@@ -10811,8 +10811,8 @@
Defined in
src/animator.ts:179src/animator.ts:174
@@ -11208,8 +11208,8 @@
Defined in
src/animator.ts:138src/animator.ts:133
diff --git a/docs/demo/demo.bundle.js b/docs/demo/demo.bundle.js
index a8b7441..88dc570 100644
--- a/docs/demo/demo.bundle.js
+++ b/docs/demo/demo.bundle.js
@@ -88021,7 +88021,6 @@ Deprecated since v${version}`
},
{ width, height, source }
) {
- var _a;
super();
/**
* When Lifecycle Object is updated, it emits this subject.
@@ -88043,7 +88042,6 @@ Deprecated since v${version}`
this.label = 'Animator';
gameObject.addChild(this);
this.stateMachine = new state_machine_1.StateMachine(gameObject);
- this.sprite = new PIXI.Container();
const tileWidth = width / cols;
const tileHeight = height / rows;
Object.values(animations).forEach((animationFrames) => {
@@ -88062,12 +88060,9 @@ Deprecated since v${version}`
})
);
animatedSprite.anchor.set(anchor.x, anchor.y);
- this.sprite.addChild(animatedSprite);
+ this.addChild(animatedSprite);
});
this.states = Object.keys(animations);
- (_a = gameObject.scene) === null || _a === void 0
- ? void 0
- : _a.stage.addChild(this.sprite);
}
/**
* Reference to inner State Machine's state.
@@ -88088,12 +88083,12 @@ Deprecated since v${version}`
return this.animation.scale;
}
update(deltaTime) {
- this.sprite.x = this.gameObject.x;
- this.sprite.y = this.gameObject.y;
+ this.x = this.gameObject.x;
+ this.y = this.gameObject.y;
lifecycle_1.Lifecycle.update(this, deltaTime);
}
setScale(x = 1, y = x) {
- this.sprite.children.forEach((child) => {
+ this.children.forEach((child) => {
child.scale.set(x, y);
});
}
@@ -88107,7 +88102,7 @@ Deprecated since v${version}`
if (animation === this.animation) {
return;
}
- const children = this.sprite.children.filter(
+ const children = this.children.filter(
(child) =>
child instanceof PIXI.AnimatedSprite && child !== animation
);
@@ -88132,7 +88127,7 @@ Deprecated since v${version}`
if (!this.stateMachine.setState(next)) {
return '';
}
- const animation = this.sprite.children[index];
+ const animation = this.children[index];
if (!loop && stateWhenFinished) {
animation.onComplete = () => {
animation.onComplete = null;
diff --git a/docs/interfaces/AnimatorData.html b/docs/interfaces/AnimatorData.html
index 57079bd..5edc979 100644
--- a/docs/interfaces/AnimatorData.html
+++ b/docs/interfaces/AnimatorData.html
@@ -109,8 +109,8 @@ Interface AnimatorData
Defined in
src/animator.ts:10src/animator.ts:9
@@ -192,8 +192,8 @@
Defined in
src/animator.ts:15src/animator.ts:14
@@ -222,8 +222,8 @@
Defined in
src/animator.ts:14src/animator.ts:13
@@ -257,8 +257,8 @@
Defined in
src/animator.ts:11src/animator.ts:10
@@ -283,8 +283,8 @@
Defined in
src/animator.ts:12src/animator.ts:11
@@ -309,8 +309,8 @@
Defined in
src/animator.ts:13src/animator.ts:12
diff --git a/package.json b/package.json
index 0b31abc..ac3e848 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@jacekpietal/oneforall",
"description": "One For All - TypeScript gamedev library inspired by Unity",
- "version": "8.0.0",
+ "version": "8.0.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
diff --git a/src/animator.ts b/src/animator.ts
index 1834f03..91b8d26 100644
--- a/src/animator.ts
+++ b/src/animator.ts
@@ -5,7 +5,6 @@ import { Subject } from 'rxjs/internal/Subject';
import { GameObject } from './game-object';
import { Lifecycle, LifecycleParent, LifecycleProps } from './lifecycle';
import { StateMachine } from './state-machine';
-import { Scene } from './scene';
export interface AnimatorData {
animations: Record;
@@ -81,9 +80,7 @@ export class Animator extends PIXI.Container implements LifecycleProps {
) {
super();
gameObject.addChild(this);
-
this.stateMachine = new StateMachine(gameObject);
- this.sprite = new PIXI.Container();
const tileWidth = width / cols;
const tileHeight = height / rows;
@@ -106,12 +103,10 @@ export class Animator extends PIXI.Container implements LifecycleProps {
);
animatedSprite.anchor.set(anchor.x, anchor.y);
- this.sprite.addChild(animatedSprite);
+ this.addChild(animatedSprite);
});
this.states = Object.keys(animations);
-
- gameObject.scene?.stage.addChild(this.sprite);
}
/**
@@ -136,13 +131,13 @@ export class Animator extends PIXI.Container implements LifecycleProps {
}
update(deltaTime: number) {
- this.sprite.x = this.gameObject.x;
- this.sprite.y = this.gameObject.y;
+ this.x = this.gameObject.x;
+ this.y = this.gameObject.y;
Lifecycle.update(this, deltaTime);
}
setScale(x = 1, y: number = x): void {
- (this.sprite.children as PIXI.AnimatedSprite[]).forEach(
+ (this.children as PIXI.AnimatedSprite[]).forEach(
(child: PIXI.AnimatedSprite) => {
child.scale.set(x, y);
}
@@ -160,7 +155,7 @@ export class Animator extends PIXI.Container implements LifecycleProps {
return;
}
- const children = this.sprite.children.filter(
+ const children = this.children.filter(
(child: PIXI.AnimatedSprite) =>
child instanceof PIXI.AnimatedSprite && child !== animation
);
@@ -191,7 +186,7 @@ export class Animator extends PIXI.Container implements LifecycleProps {
return '';
}
- const animation = this.sprite.children[index] as PIXI.AnimatedSprite;
+ const animation = this.children[index] as PIXI.AnimatedSprite;
if (!loop && stateWhenFinished) {
animation.onComplete = () => {
animation.onComplete = null;