react-simple-game-engine 0.2.52 → 0.2.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,9 @@
1
1
  import { Initialler } from "../../export-interfaces";
2
- import { SourceType, Sprite } from "../sprites/sprite";
2
+ import { Sprite } from "../sprites/sprite";
3
3
  import { AnimationSprite } from "./animation";
4
- declare type AnimatorState<O extends Sprite<any> = Sprite<any>> = Sprite<SourceType> | AnimationSprite<O>;
5
4
  declare type AnimatorInitialParams<O extends Sprite<any> = Sprite<any>> = {
6
5
  activeKey: any;
7
- states: Record<any, AnimatorState<O>>;
6
+ states: Record<any, AnimationSprite<O>>;
8
7
  };
9
8
  export declare class Animator<O extends Sprite<any> = Sprite<any>> implements Initialler<AnimatorInitialParams<O>> {
10
9
  private states;
@@ -12,7 +11,7 @@ export declare class Animator<O extends Sprite<any> = Sprite<any>> implements In
12
11
  initial(params: AnimatorInitialParams<O>): void;
13
12
  linkSprite(sprite: Sprite<any>): void;
14
13
  draw(): void;
15
- getActiveAnimation(): AnimatorState<O>;
14
+ getActiveAnimation(): AnimationSprite<O>;
16
15
  set state(k: any);
17
16
  }
18
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,aAAK,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,IAClD,MAAM,CAAC,UAAU,CAAC,GAClB,eAAe,CAAC,CAAC,CAAC,CAAC;AAEvB,aAAK,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,MAA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C,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAIxC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;IAU9B,IAAI;IAIJ,kBAAkB;IAIlB,IAAI,KAAK,CAAC,CAAC,EAAE,GAAG,EAEf;CACF"}
@@ -1,5 +1,4 @@
1
1
  import { copyProperties } from "../../utils";
2
- import { AnimationSprite } from "./animation";
3
2
  var Animator = /** @class */ (function () {
4
3
  function Animator() {
5
4
  }
@@ -10,10 +9,8 @@ var Animator = /** @class */ (function () {
10
9
  for (var key in this.states) {
11
10
  if (this.states.hasOwnProperty(key)) {
12
11
  var state = this.states[key];
13
- if (state instanceof AnimationSprite) {
14
- //@ts-ignore,pass check modifier for first initial
15
- state._sprite = sprite;
16
- }
12
+ //@ts-ignore,pass check modifier for first initial
13
+ state._sprite = sprite;
17
14
  }
18
15
  }
19
16
  };
@@ -7,10 +7,11 @@ declare type Offset = {
7
7
  width: number;
8
8
  height: number;
9
9
  distancePerFrame?: number;
10
+ maxFrame?: number;
10
11
  };
11
12
  export declare class AvatarAnimationSprite extends AnimationSprite<AvatarSprite> {
12
13
  private offset;
13
- initial({ x, y, width, height, distancePerFrame, ...params }: AnimationInitialParams<Partial<Offset>>): void;
14
+ initial({ x, y, width, height, distancePerFrame, maxFrame, ...params }: AnimationInitialParams<Partial<Offset>>): void;
14
15
  protected checkFrameMax(): boolean;
15
16
  onDraw(): void;
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/avatar.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,aAAK,MAAM,GAAG;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,YAAY,CAAC;IACtE,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,EACN,CAAK,EACL,CAAK,EACL,KAAS,EACT,MAAU,EACV,gBAAoB,EACpB,GAAG,MAAM,EACV,EAAE,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAW1C,SAAS,CAAC,aAAa,IAAI,OAAO;IAQlC,MAAM;CAgBP"}
1
+ {"version":3,"file":"avatar.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/avatar.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,aAAK,MAAM,GAAG;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,YAAY,CAAC;IACtE,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,EACN,CAAK,EACL,CAAK,EACL,KAAS,EACT,MAAU,EACV,gBAAoB,EACpB,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAY1C,SAAS,CAAC,aAAa,IAAI,OAAO;IAYlC,MAAM;CAgBP"}
@@ -32,18 +32,22 @@ var AvatarAnimationSprite = /** @class */ (function (_super) {
32
32
  return _super !== null && _super.apply(this, arguments) || this;
33
33
  }
34
34
  AvatarAnimationSprite.prototype.initial = function (_a) {
35
- var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, _d = _a.width, width = _d === void 0 ? 0 : _d, _e = _a.height, height = _e === void 0 ? 0 : _e, _f = _a.distancePerFrame, distancePerFrame = _f === void 0 ? 0 : _f, params = __rest(_a, ["x", "y", "width", "height", "distancePerFrame"]);
35
+ var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, _d = _a.width, width = _d === void 0 ? 0 : _d, _e = _a.height, height = _e === void 0 ? 0 : _e, _f = _a.distancePerFrame, distancePerFrame = _f === void 0 ? 0 : _f, maxFrame = _a.maxFrame, params = __rest(_a, ["x", "y", "width", "height", "distancePerFrame", "maxFrame"]);
36
36
  this.offset = {
37
37
  x: x,
38
38
  y: y,
39
39
  width: width,
40
40
  height: height,
41
41
  distancePerFrame: distancePerFrame,
42
+ maxFrame: maxFrame,
42
43
  };
43
44
  copyProperties(this, params);
44
45
  };
45
46
  AvatarAnimationSprite.prototype.checkFrameMax = function () {
46
- var _a = this.offset, width = _a.width, x = _a.x, distancePerFrame = _a.distancePerFrame;
47
+ var _a = this.offset, width = _a.width, x = _a.x, distancePerFrame = _a.distancePerFrame, maxFrame = _a.maxFrame;
48
+ if (maxFrame != null) {
49
+ return this.currentFrame === maxFrame;
50
+ }
47
51
  return (x + this.currentFrame * (width + distancePerFrame) >=
48
52
  this.sprite.source.width);
49
53
  };
@@ -2,7 +2,11 @@ import { ColorSprite } from "../sprites/color.sprite";
2
2
  import { AnimationSprite } from "./animation";
3
3
  export declare class ColorAnimationSprite extends AnimationSprite<ColorSprite> {
4
4
  private colors;
5
- initial(colors: ColorSprite["source"][]): void;
5
+ private maxFrame?;
6
+ initial(params: {
7
+ colors: ColorSprite["source"][];
8
+ maxFrame?: number;
9
+ }): void;
6
10
  protected checkFrameMax(): boolean;
7
11
  protected onDraw(): void;
8
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"color.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/color.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,oBAAqB,SAAQ,eAAe,CAAC,WAAW,CAAC;IACpE,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE;IAIvC,SAAS,CAAC,aAAa,IAAI,OAAO;IAIlC,SAAS,CAAC,MAAM,IAAI,IAAI;CAGzB"}
1
+ {"version":3,"file":"color.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/color.animation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,oBAAqB,SAAQ,eAAe,CAAC,WAAW,CAAC;IACpE,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAAC,CAAS;IAE1B,OAAO,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;IAItE,SAAS,CAAC,aAAa,IAAI,OAAO;IAQlC,SAAS,CAAC,MAAM,IAAI,IAAI;CAGzB"}
@@ -13,16 +13,20 @@ var __extends = (this && this.__extends) || (function () {
13
13
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
14
  };
15
15
  })();
16
+ import { copyProperties } from "../../utils";
16
17
  import { AnimationSprite } from "./animation";
17
18
  var ColorAnimationSprite = /** @class */ (function (_super) {
18
19
  __extends(ColorAnimationSprite, _super);
19
20
  function ColorAnimationSprite() {
20
21
  return _super !== null && _super.apply(this, arguments) || this;
21
22
  }
22
- ColorAnimationSprite.prototype.initial = function (colors) {
23
- this.colors = colors;
23
+ ColorAnimationSprite.prototype.initial = function (params) {
24
+ copyProperties(this, params);
24
25
  };
25
26
  ColorAnimationSprite.prototype.checkFrameMax = function () {
27
+ if (this.maxFrame != null) {
28
+ return this.currentFrame === this.maxFrame;
29
+ }
26
30
  return this.currentFrame >= this.colors.length;
27
31
  };
28
32
  ColorAnimationSprite.prototype.onDraw = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.2.52",
3
+ "version": "0.2.54",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",