react-simple-game-engine 0.1.23 → 0.1.26
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.
@@ -4,13 +4,17 @@ import { CreateBodyDefine, EntityInitial, EntityPrepare, MasterBody, Sound } fro
|
|
4
4
|
import { EntitySult } from "./entity-sult";
|
5
5
|
import { LogicComponent } from "../logic-component";
|
6
6
|
declare type TimerJobListener = () => void;
|
7
|
+
declare type TerminateOptions = {
|
8
|
+
duration?: number;
|
9
|
+
effect: EntitySult | LogicComponent<EntitySult>;
|
10
|
+
};
|
7
11
|
export declare abstract class Entity<P extends Record<string, any> = Record<string, any>> extends EntitySult<EntityInitial<Entity>> {
|
8
12
|
private _body;
|
9
13
|
private _sprite;
|
10
14
|
private _children;
|
11
15
|
private _props;
|
12
16
|
private timerJobListeners;
|
13
|
-
private
|
17
|
+
private isTerminate;
|
14
18
|
enabledGravity: boolean;
|
15
19
|
sound?: Sound;
|
16
20
|
set sprite(sprite: Sprite<any>);
|
@@ -20,10 +24,12 @@ export declare abstract class Entity<P extends Record<string, any> = Record<stri
|
|
20
24
|
get children(): EntitySult<any>[];
|
21
25
|
get props(): P;
|
22
26
|
/**
|
23
|
-
* @param {
|
27
|
+
* @param {TerminateOptions} options
|
28
|
+
* #duration: time to disappear from the world in seconds, default: 0.2 seconds
|
29
|
+
* #effect: effect to showing on duration time
|
24
30
|
* @void
|
25
31
|
*/
|
26
|
-
|
32
|
+
terminate(options?: TerminateOptions): void;
|
27
33
|
/**
|
28
34
|
* @param {string} name
|
29
35
|
* @param {number} interval in seconds
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAwB,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EAC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,aAAa,CAAC,IAAI,CAAC;IACnD,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAI1C,MAAM;IAiBN,QAAQ;IAER,IAAI;IAIJ,QAAQ,CAAC,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAExE,WAAW,CAAC,MAAM,EAAE,MAAM;IAC1B,cAAc,CAAC,MAAM,EAAE,MAAM;IAC7B,iBAAiB,CAAC,MAAM,EAAE,MAAM;CACjC"}
|
@@ -46,7 +46,7 @@ var Entity = /** @class */ (function (_super) {
|
|
46
46
|
_this._children = [];
|
47
47
|
_this._props = {};
|
48
48
|
_this.timerJobListeners = {};
|
49
|
-
_this.
|
49
|
+
_this.isTerminate = false;
|
50
50
|
_this.enabledGravity = true;
|
51
51
|
return _this;
|
52
52
|
}
|
@@ -90,20 +90,30 @@ var Entity = /** @class */ (function (_super) {
|
|
90
90
|
configurable: true
|
91
91
|
});
|
92
92
|
/**
|
93
|
-
* @param {
|
93
|
+
* @param {TerminateOptions} options
|
94
|
+
* #duration: time to disappear from the world in seconds, default: 0.2 seconds
|
95
|
+
* #effect: effect to showing on duration time
|
94
96
|
* @void
|
95
97
|
*/
|
96
|
-
Entity.prototype.
|
98
|
+
Entity.prototype.terminate = function (options) {
|
97
99
|
var _this = this;
|
98
|
-
if (
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
100
|
+
if (options) {
|
101
|
+
var _a = options.duration, duration = _a === void 0 ? 0.2 : _a, effect = options.effect;
|
102
|
+
this.isTerminate = true;
|
103
|
+
Body.setVelocity(this.body, {
|
104
|
+
y: 0,
|
105
|
+
x: 0,
|
106
|
+
});
|
107
|
+
this.sprite = new ColorSprite();
|
108
|
+
this.sprite.source = [0, 0, 0, 0];
|
109
|
+
this.addChild(effect);
|
110
|
+
setTimeout(function () {
|
111
|
+
_this.worldManagement.removeEntity(_this);
|
112
|
+
}, duration * 1000);
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
this.worldManagement.removeEntity(this);
|
116
|
+
}
|
107
117
|
};
|
108
118
|
/**
|
109
119
|
* @param {string} name
|
@@ -163,7 +173,7 @@ var Entity = /** @class */ (function (_super) {
|
|
163
173
|
return {};
|
164
174
|
};
|
165
175
|
Entity.prototype.update = function () {
|
166
|
-
if (this.
|
176
|
+
if (!this.isTerminate) {
|
167
177
|
this.onUpdate();
|
168
178
|
}
|
169
179
|
for (var name_1 in this.timerJobListeners) {
|