@rpgjs/client 3.3.2 → 4.0.0-beta.3
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.
- package/LICENSE +19 -0
- package/lib/Components/AbstractComponent.d.ts +3 -2
- package/lib/Components/AbstractComponent.js +17 -28
- package/lib/Components/AbstractComponent.js.map +1 -1
- package/lib/Components/BarComponent.d.ts +2 -1
- package/lib/Components/BarComponent.js +32 -33
- package/lib/Components/BarComponent.js.map +1 -1
- package/lib/Components/Component.d.ts +3 -3
- package/lib/Components/Component.js +84 -96
- package/lib/Components/Component.js.map +1 -1
- package/lib/Components/DebugComponent.d.ts +2 -1
- package/lib/Components/DebugComponent.js +9 -10
- package/lib/Components/DebugComponent.js.map +1 -1
- package/lib/Components/ImageComponent.d.ts +2 -1
- package/lib/Components/ImageComponent.js +5 -7
- package/lib/Components/ImageComponent.js.map +1 -1
- package/lib/Components/ShapeComponent.d.ts +2 -1
- package/lib/Components/ShapeComponent.js +14 -14
- package/lib/Components/ShapeComponent.js.map +1 -1
- package/lib/Components/TextComponent.d.ts +3 -2
- package/lib/Components/TextComponent.js +10 -9
- package/lib/Components/TextComponent.js.map +1 -1
- package/lib/Components/TileComponent.d.ts +2 -1
- package/lib/Components/TileComponent.js +12 -16
- package/lib/Components/TileComponent.js.map +1 -1
- package/lib/Effects/Animation.d.ts +10 -9
- package/lib/Effects/Animation.js +36 -36
- package/lib/Effects/Animation.js.map +1 -1
- package/lib/Effects/AnimationCharacter.js +2 -5
- package/lib/Effects/AnimationCharacter.js.map +1 -1
- package/lib/Effects/Spinner.d.ts +3 -2
- package/lib/Effects/Spinner.js +2 -5
- package/lib/Effects/Spinner.js.map +1 -1
- package/lib/Effects/Timeline.d.ts +1 -1
- package/lib/Effects/Timeline.js +6 -10
- package/lib/Effects/Timeline.js.map +1 -1
- package/lib/Effects/TransitionScene.d.ts +2 -1
- package/lib/Effects/TransitionScene.js +3 -7
- package/lib/Effects/TransitionScene.js.map +1 -1
- package/lib/GameEngine.js +51 -26
- package/lib/GameEngine.js.map +1 -1
- package/lib/Interfaces/Character.js +1 -2
- package/lib/Interfaces/Scene.js +1 -2
- package/lib/KeyboardControls.d.ts +2 -1
- package/lib/KeyboardControls.js +47 -45
- package/lib/KeyboardControls.js.map +1 -1
- package/lib/Logger.js +1 -5
- package/lib/Logger.js.map +1 -1
- package/lib/Presets/AnimationSpritesheet.js +9 -13
- package/lib/Presets/AnimationSpritesheet.js.map +1 -1
- package/lib/Presets/Scene.js +2 -5
- package/lib/Presets/Scene.js.map +1 -1
- package/lib/Renderer.d.ts +5 -3
- package/lib/Renderer.js +68 -60
- package/lib/Renderer.js.map +1 -1
- package/lib/Resources.js +1 -5
- package/lib/Resources.js.map +1 -1
- package/lib/RpgClient.d.ts +3 -2
- package/lib/RpgClient.js +1 -2
- package/lib/RpgClientEngine.d.ts +2 -1
- package/lib/RpgClientEngine.js +192 -176
- package/lib/RpgClientEngine.js.map +1 -1
- package/lib/RpgGui.js +40 -41
- package/lib/RpgGui.js.map +1 -1
- package/lib/Scene/EventLayer.d.ts +4 -0
- package/lib/Scene/EventLayer.js +8 -0
- package/lib/Scene/EventLayer.js.map +1 -0
- package/lib/Scene/Map.d.ts +17 -3
- package/lib/Scene/Map.js +157 -113
- package/lib/Scene/Map.js.map +1 -1
- package/lib/Scene/Scene.d.ts +3 -3
- package/lib/Scene/Scene.js +24 -20
- package/lib/Scene/Scene.js.map +1 -1
- package/lib/Scene/SceneData.js +1 -5
- package/lib/Scene/SceneData.js.map +1 -1
- package/lib/Sound/RpgSound.js +8 -11
- package/lib/Sound/RpgSound.js.map +1 -1
- package/lib/Sound/Sound.d.ts +2 -2
- package/lib/Sound/Sound.js +1 -5
- package/lib/Sound/Sound.js.map +1 -1
- package/lib/Sound/Sounds.js +4 -8
- package/lib/Sound/Sounds.js.map +1 -1
- package/lib/Sprite/Character.d.ts +3 -2
- package/lib/Sprite/Character.js +15 -16
- package/lib/Sprite/Character.js.map +1 -1
- package/lib/Sprite/Player.js +2 -9
- package/lib/Sprite/Player.js.map +1 -1
- package/lib/Sprite/Spritesheet.d.ts +4 -4
- package/lib/Sprite/Spritesheet.js +1 -5
- package/lib/Sprite/Spritesheet.js.map +1 -1
- package/lib/Sprite/Spritesheets.js +4 -8
- package/lib/Sprite/Spritesheets.js.map +1 -1
- package/lib/Tilemap/CommonLayer.d.ts +2 -1
- package/lib/Tilemap/CommonLayer.js +7 -11
- package/lib/Tilemap/CommonLayer.js.map +1 -1
- package/lib/Tilemap/ImageLayer.js +5 -7
- package/lib/Tilemap/ImageLayer.js.map +1 -1
- package/lib/Tilemap/Tile.d.ts +5 -5
- package/lib/Tilemap/Tile.js +19 -21
- package/lib/Tilemap/Tile.js.map +1 -1
- package/lib/Tilemap/TileLayer.d.ts +0 -7
- package/lib/Tilemap/TileLayer.js +27 -29
- package/lib/Tilemap/TileLayer.js.map +1 -1
- package/lib/Tilemap/TileSet.d.ts +2 -1
- package/lib/Tilemap/TileSet.js +9 -12
- package/lib/Tilemap/TileSet.js.map +1 -1
- package/lib/Tilemap/index.d.ts +3 -11
- package/lib/Tilemap/index.js +22 -61
- package/lib/Tilemap/index.js.map +1 -1
- package/lib/clientEntryPoint.js +26 -28
- package/lib/clientEntryPoint.js.map +1 -1
- package/lib/index.js +21 -75
- package/lib/index.js.map +1 -1
- package/package.json +19 -19
- package/src/Components/AbstractComponent.ts +120 -0
- package/src/Components/BarComponent.ts +179 -0
- package/src/Components/Component.ts +506 -0
- package/src/Components/DebugComponent.ts +36 -0
- package/src/Components/ImageComponent.ts +30 -0
- package/src/Components/ShapeComponent.ts +64 -0
- package/src/Components/TextComponent.ts +33 -0
- package/src/Components/TileComponent.ts +43 -0
- package/src/Effects/Animation.ts +297 -0
- package/src/Effects/AnimationCharacter.ts +7 -0
- package/src/Effects/Spinner.ts +19 -0
- package/src/Effects/Timeline.ts +294 -0
- package/src/Effects/TransitionScene.ts +57 -0
- package/src/GameEngine.ts +284 -0
- package/src/Interfaces/Character.ts +7 -0
- package/src/Interfaces/Scene.ts +9 -0
- package/src/KeyboardControls.ts +552 -0
- package/src/Logger.ts +3 -0
- package/src/Presets/AnimationSpritesheet.ts +36 -0
- package/src/Presets/Scene.ts +3 -0
- package/src/Renderer.ts +263 -0
- package/src/Resources.ts +40 -0
- package/src/RpgClient.ts +333 -0
- package/src/RpgClientEngine.ts +709 -0
- package/src/RpgGui.ts +553 -0
- package/src/RpgGuiCompiled.ts +43 -0
- package/src/Scene/EventLayer.ts +9 -0
- package/src/Scene/Map.ts +393 -0
- package/src/Scene/Scene.ts +270 -0
- package/src/Scene/SceneData.ts +13 -0
- package/src/Sound/RpgSound.ts +50 -0
- package/src/Sound/Sound.ts +91 -0
- package/src/Sound/Sounds.ts +7 -0
- package/src/Sprite/Character.ts +149 -0
- package/src/Sprite/Player.ts +3 -0
- package/src/Sprite/Spritesheet.ts +392 -0
- package/src/Sprite/Spritesheets.ts +8 -0
- package/src/Tilemap/CommonLayer.ts +20 -0
- package/src/Tilemap/ImageLayer.ts +20 -0
- package/src/Tilemap/Tile.ts +80 -0
- package/src/Tilemap/TileLayer.ts +142 -0
- package/src/Tilemap/TileSet.ts +40 -0
- package/src/Tilemap/index.ts +173 -0
- package/src/clientEntryPoint.ts +141 -0
- package/src/index.ts +25 -0
- package/src/types/howler.d.ts +73 -0
- package/tsconfig.json +30 -0
- package/lib/Components/ColorComponent.d.ts +0 -9
- package/lib/Components/ColorComponent.js +0 -18
- package/lib/Components/ColorComponent.js.map +0 -1
package/lib/Sound/Sound.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ interface SoundOptions {
|
|
|
28
28
|
* */
|
|
29
29
|
volume?: number;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
type SoundIdOptions = SoundOptions & {
|
|
32
32
|
/**
|
|
33
33
|
* Sound identifier.
|
|
34
34
|
*
|
|
@@ -53,7 +53,7 @@ declare type SoundIdOptions = SoundOptions & {
|
|
|
53
53
|
* */
|
|
54
54
|
sound: string;
|
|
55
55
|
};
|
|
56
|
-
|
|
56
|
+
type SoundIdsOptions = SoundOptions & {
|
|
57
57
|
/**
|
|
58
58
|
* Put the different sounds that are concerned by the properties below.
|
|
59
59
|
* The key of the object is the identifier of the sound and the value and the link to the sound.
|
package/lib/Sound/Sound.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Sound = void 0;
|
|
4
|
-
function Sound(options) {
|
|
1
|
+
export function Sound(options) {
|
|
5
2
|
return (target) => {
|
|
6
3
|
if ('sounds' in options)
|
|
7
4
|
target['sounds'] = options.sounds;
|
|
@@ -12,5 +9,4 @@ function Sound(options) {
|
|
|
12
9
|
}
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
|
-
exports.Sound = Sound;
|
|
16
12
|
//# sourceMappingURL=Sound.js.map
|
package/lib/Sound/Sound.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/Sound/Sound.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/Sound/Sound.ts"],"names":[],"mappings":"AAkFA,MAAM,UAAU,KAAK,CAAC,OAAyC;IAC3D,OAAO,CAAC,MAAgB,EAAE,EAAE;QACxB,IAAI,QAAQ,IAAI,OAAO;YAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAA;QAC3D,IAAI,IAAI,IAAI,OAAO;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,EAAE,CAAA;QAC9C,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;YACrB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;SACvC;IACL,CAAC,CAAA;AACL,CAAC"}
|
package/lib/Sound/Sounds.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.sounds = new Map();
|
|
6
|
-
function _initSound(_sounds, engine) {
|
|
7
|
-
return (0, Resources_1._initResource)(exports.sounds, _sounds, 'sound', engine);
|
|
1
|
+
import { _initResource } from '../Resources';
|
|
2
|
+
export const sounds = new Map();
|
|
3
|
+
export function _initSound(_sounds, engine) {
|
|
4
|
+
return _initResource(sounds, _sounds, 'sound', engine);
|
|
8
5
|
}
|
|
9
|
-
exports._initSound = _initSound;
|
|
10
6
|
//# sourceMappingURL=Sounds.js.map
|
package/lib/Sound/Sounds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sounds.js","sourceRoot":"","sources":["../../src/Sound/Sounds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sounds.js","sourceRoot":"","sources":["../../src/Sound/Sounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,CAAA;AAE/B,MAAM,UAAU,UAAU,CAAC,OAAO,EAAE,MAAM;IACtC,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAC1D,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Animation } from '../Effects/Animation';
|
|
2
2
|
import { RpgComponent } from '../Components/Component';
|
|
3
|
-
|
|
3
|
+
import { Sprite } from 'pixi.js';
|
|
4
|
+
export default class Character extends Sprite {
|
|
4
5
|
private component;
|
|
5
6
|
private graphic;
|
|
6
7
|
static readonly id: string;
|
|
@@ -12,6 +13,6 @@ export default class Character extends PIXI.Sprite {
|
|
|
12
13
|
constructor(component: RpgComponent, graphic: string);
|
|
13
14
|
getGraphicHeight(): number;
|
|
14
15
|
getGraphicWidth(): number;
|
|
15
|
-
animationSprite(): import("rxjs").Observable<
|
|
16
|
+
animationSprite(): import("rxjs").Observable<Sprite | null>;
|
|
16
17
|
private setAnimationAnchor;
|
|
17
18
|
}
|
package/lib/Sprite/Character.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
class Character extends PIXI.Sprite {
|
|
1
|
+
import { Utils, RpgPlugin, HookClient } from '@rpgjs/common';
|
|
2
|
+
import { spritesheets } from './Spritesheets';
|
|
3
|
+
import { Animation } from '../Effects/Animation';
|
|
4
|
+
import { Animation as AnimationEnum } from '../Effects/AnimationCharacter';
|
|
5
|
+
import { Sprite } from 'pixi.js';
|
|
6
|
+
const { capitalize } = Utils;
|
|
7
|
+
class Character extends Sprite {
|
|
9
8
|
constructor(component, graphic) {
|
|
10
9
|
super();
|
|
11
10
|
this.component = component;
|
|
@@ -24,13 +23,13 @@ class Character extends PIXI.Sprite {
|
|
|
24
23
|
showAnimation(graphic, animationName) {
|
|
25
24
|
const refreshAnimation = (graphic) => {
|
|
26
25
|
this.removeChild(this.animation);
|
|
27
|
-
this.animation = new
|
|
26
|
+
this.animation = new Animation(graphic);
|
|
28
27
|
this.addChild(this.animation);
|
|
29
28
|
this.setAnimationAnchor();
|
|
30
29
|
};
|
|
31
30
|
const memoryGraphic = this.graphic;
|
|
32
31
|
let graphicId = '';
|
|
33
|
-
if (
|
|
32
|
+
if (Utils.isArray(graphic)) {
|
|
34
33
|
graphicId = graphic.find(id => id == this.graphic);
|
|
35
34
|
}
|
|
36
35
|
else {
|
|
@@ -54,8 +53,8 @@ class Character extends PIXI.Sprite {
|
|
|
54
53
|
}
|
|
55
54
|
});
|
|
56
55
|
this.graphic = graphic;
|
|
57
|
-
this.spritesheet =
|
|
58
|
-
this.animation = new
|
|
56
|
+
this.spritesheet = spritesheets.get(this.graphic);
|
|
57
|
+
this.animation = new Animation(this.graphic);
|
|
59
58
|
this.addChild(this.animation);
|
|
60
59
|
this.setAnimationAnchor();
|
|
61
60
|
}
|
|
@@ -95,11 +94,11 @@ class Character extends PIXI.Sprite {
|
|
|
95
94
|
this.animation.update(deltaRatio);
|
|
96
95
|
if (this.playStandardAnimation) {
|
|
97
96
|
if (moving) {
|
|
98
|
-
|
|
99
|
-
this.playAnimation(
|
|
97
|
+
RpgPlugin.emit(HookClient.SpriteMove, this);
|
|
98
|
+
this.playAnimation(AnimationEnum.Walk);
|
|
100
99
|
}
|
|
101
100
|
else {
|
|
102
|
-
this.playAnimation(
|
|
101
|
+
this.playAnimation(AnimationEnum.Stand);
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
this.objSaved = obj;
|
|
@@ -121,6 +120,6 @@ class Character extends PIXI.Sprite {
|
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
|
-
exports.default = Character;
|
|
125
123
|
Character.id = 'graphic';
|
|
124
|
+
export default Character;
|
|
126
125
|
//# sourceMappingURL=Character.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Character.js","sourceRoot":"","sources":["../../src/Sprite/Character.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Character.js","sourceRoot":"","sources":["../../src/Sprite/Character.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAG1E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;AAE5B,MAAqB,SAAU,SAAQ,MAAM;IAiBzC,YAAoB,SAAuB,EAAU,OAAe;QAChE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AAU,CAAC,IAAI,CAAC,EAAE,CAAA;QAC7C,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAM;QAC7B,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;YACxB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAA;SAC/B;aACI,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC/B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;SACnD;IACL,CAAC;;AAvIe,YAAE,GAAW,SAAS,AAApB,CAAoB;eADrB,SAAS"}
|
package/lib/Sprite/Player.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RpgSprite = void 0;
|
|
7
|
-
const Character_1 = __importDefault(require("./Character"));
|
|
8
|
-
class RpgSprite extends Character_1.default {
|
|
1
|
+
import Character from './Character';
|
|
2
|
+
export class RpgSprite extends Character {
|
|
9
3
|
}
|
|
10
|
-
exports.RpgSprite = RpgSprite;
|
|
11
4
|
//# sourceMappingURL=Player.js.map
|
package/lib/Sprite/Player.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Player.js","sourceRoot":"","sources":["../../src/Sprite/Player.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Player.js","sourceRoot":"","sources":["../../src/Sprite/Player.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AAEnC,MAAM,OAAO,SAAU,SAAQ,SAAS;CAAG"}
|
|
@@ -188,7 +188,7 @@ export interface TextureOptions {
|
|
|
188
188
|
y: number;
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
export
|
|
191
|
+
export type AnimationFrames = FrameOptions[][] | ((...args: any) => FrameOptions[][]);
|
|
192
192
|
export interface TexturesOptions extends TextureOptions, TransformOptions {
|
|
193
193
|
animations: AnimationFrames;
|
|
194
194
|
}
|
|
@@ -315,7 +315,7 @@ export interface SpritesheetOptions extends TransformOptions, TextureOptions {
|
|
|
315
315
|
[animationName: string]: Partial<TexturesOptions> & Pick<TexturesOptions, 'animations'>;
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
|
-
|
|
318
|
+
type SpritesheetImageOptions = SpritesheetOptions & {
|
|
319
319
|
/**
|
|
320
320
|
* The link to the image
|
|
321
321
|
*
|
|
@@ -340,7 +340,7 @@ declare type SpritesheetImageOptions = SpritesheetOptions & {
|
|
|
340
340
|
* */
|
|
341
341
|
id: string;
|
|
342
342
|
};
|
|
343
|
-
|
|
343
|
+
type SpritesheetImagesOptions = SpritesheetOptions & {
|
|
344
344
|
/**
|
|
345
345
|
* Put the different images that are concerned by the properties below.
|
|
346
346
|
* The key of the object is the identifier of the spritesheet and the value and the link to the image.
|
|
@@ -356,7 +356,7 @@ declare type SpritesheetImagesOptions = SpritesheetOptions & {
|
|
|
356
356
|
* @prop { { [id: string]: string } } [images]
|
|
357
357
|
* @memberof Spritesheet
|
|
358
358
|
* */
|
|
359
|
-
images
|
|
359
|
+
images?: {
|
|
360
360
|
[id: string]: string;
|
|
361
361
|
};
|
|
362
362
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Spritesheet = void 0;
|
|
4
|
-
function Spritesheet(options) {
|
|
1
|
+
export function Spritesheet(options) {
|
|
5
2
|
return (target) => {
|
|
6
3
|
if ('images' in options)
|
|
7
4
|
target['images'] = options.images;
|
|
@@ -13,5 +10,4 @@ function Spritesheet(options) {
|
|
|
13
10
|
return;
|
|
14
11
|
};
|
|
15
12
|
}
|
|
16
|
-
exports.Spritesheet = Spritesheet;
|
|
17
13
|
//# sourceMappingURL=Spritesheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spritesheet.js","sourceRoot":"","sources":["../../src/Sprite/Spritesheet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Spritesheet.js","sourceRoot":"","sources":["../../src/Sprite/Spritesheet.ts"],"names":[],"mappings":"AA8XA,MAAM,UAAU,WAAW,CAAC,OAA2D;IACnF,OAAO,CAAC,MAAgB,EAAE,EAAE;QACxB,IAAI,QAAQ,IAAI,OAAO;YAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAA;QAC1D,IAAI,IAAI,IAAI,OAAO;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,EAAE,CAAA;QAC9C,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;YACrB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;SACvC;QACD,OAAM;IACV,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.spritesheets = new Map();
|
|
6
|
-
function _initSpritesheet(_spritesheets, engine) {
|
|
7
|
-
return (0, Resources_1._initResource)(exports.spritesheets, _spritesheets, 'image', engine);
|
|
1
|
+
import { _initResource } from '../Resources';
|
|
2
|
+
export const spritesheets = new Map();
|
|
3
|
+
export function _initSpritesheet(_spritesheets, engine) {
|
|
4
|
+
return _initResource(spritesheets, _spritesheets, 'image', engine);
|
|
8
5
|
}
|
|
9
|
-
exports._initSpritesheet = _initSpritesheet;
|
|
10
6
|
//# sourceMappingURL=Spritesheets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spritesheets.js","sourceRoot":"","sources":["../../src/Sprite/Spritesheets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Spritesheets.js","sourceRoot":"","sources":["../../src/Sprite/Spritesheets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAqB,IAAI,GAAG,EAAE,CAAA;AAEvD,MAAM,UAAU,gBAAgB,CAAC,aAAa,EAAE,MAAuB;IACnE,OAAO,aAAa,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AACtE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Layer } from "@rpgjs/tiled";
|
|
2
2
|
import TileMap from './index';
|
|
3
|
-
|
|
3
|
+
import { Container } from "pixi.js";
|
|
4
|
+
export declare class CommonLayer extends Container {
|
|
4
5
|
protected layer: Layer;
|
|
5
6
|
protected map: TileMap;
|
|
6
7
|
z: number;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CommonLayer = void 0;
|
|
4
|
-
class CommonLayer extends PIXI.Container {
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
export class CommonLayer extends Container {
|
|
5
3
|
constructor(layer, map) {
|
|
6
4
|
super();
|
|
7
5
|
this.layer = layer;
|
|
@@ -9,13 +7,11 @@ class CommonLayer extends PIXI.Container {
|
|
|
9
7
|
this.applyProperties();
|
|
10
8
|
}
|
|
11
9
|
applyProperties() {
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.z = (_e = this.layer.properties.z) !== null && _e !== void 0 ? _e : 0;
|
|
10
|
+
this.alpha = this.layer.opacity ?? 1;
|
|
11
|
+
this.visible = this.layer.visible ?? true;
|
|
12
|
+
this.x = this.layer.offsetx ?? 0;
|
|
13
|
+
this.y = this.layer.offsety ?? 0;
|
|
14
|
+
this.z = this.layer.properties.z ?? 0;
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.CommonLayer = CommonLayer;
|
|
21
17
|
//# sourceMappingURL=CommonLayer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonLayer.js","sourceRoot":"","sources":["../../src/Tilemap/CommonLayer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CommonLayer.js","sourceRoot":"","sources":["../../src/Tilemap/CommonLayer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,OAAO,WAAY,SAAQ,SAAS;IAGtC,YAAsB,KAAY,EAAY,GAAY;QACtD,KAAK,EAAE,CAAA;QADW,UAAK,GAAL,KAAK,CAAO;QAAY,QAAG,GAAH,GAAG,CAAS;QAEtD,IAAI,CAAC,eAAe,EAAE,CAAA;IAC1B,CAAC;IAED,eAAe;QACX,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAA;QACzC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA;QAChC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA;QAChC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;CACJ"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class ImageLayer extends CommonLayer_1.CommonLayer {
|
|
1
|
+
import { CommonLayer } from './CommonLayer';
|
|
2
|
+
import { Texture, TilingSprite } from 'pixi.js';
|
|
3
|
+
export default class ImageLayer extends CommonLayer {
|
|
5
4
|
applyProperties() {
|
|
6
5
|
super.applyProperties();
|
|
7
6
|
const engine = this.map['renderer']['clientEngine'];
|
|
8
7
|
if (this.layer.image && this.layer.image.source && engine) {
|
|
9
8
|
const { width, height, source } = this.layer.image;
|
|
10
9
|
const data = this.map.getData();
|
|
11
|
-
const texture =
|
|
12
|
-
const tilingSprite = new
|
|
10
|
+
const texture = Texture.from(engine.getResourceUrl(source));
|
|
11
|
+
const tilingSprite = new TilingSprite(texture, this.layer.repeatx ? data.width * data.tilewidth : width, this.layer.repeaty ? data.height * data.tileheight : height);
|
|
13
12
|
this.addChild(tilingSprite);
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
exports.default = ImageLayer;
|
|
18
16
|
//# sourceMappingURL=ImageLayer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageLayer.js","sourceRoot":"","sources":["../../src/Tilemap/ImageLayer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageLayer.js","sourceRoot":"","sources":["../../src/Tilemap/ImageLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,eAAe;QACb,KAAK,CAAC,eAAe,EAAE,CAAA;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,CAAA;QACnD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,MAAM,EAAE;YACzD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;YAClD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;YAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;YAC3D,MAAM,YAAY,GAAG,IAAI,YAAY,CACjC,OAAO,EACP,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAC9D,CAAA;YACD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;SAC5B;IACH,CAAC;CACF"}
|
package/lib/Tilemap/Tile.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Texture } from "pixi.js";
|
|
2
|
-
import { RpgRectTileLayer } from "./TileLayer";
|
|
1
|
+
import { Texture, AnimatedSprite } from "pixi.js";
|
|
3
2
|
import TileSet from "./TileSet";
|
|
4
3
|
import { Tile as TiledTileClass } from '@rpgjs/tiled';
|
|
5
|
-
|
|
4
|
+
import { CompositeTilemap } from "@pixi/tilemap";
|
|
5
|
+
export default class Tile extends AnimatedSprite {
|
|
6
6
|
private tile;
|
|
7
7
|
private tileSet;
|
|
8
|
-
static getTextures(tile: TiledTileClass, tileSet: TileSet): Texture[];
|
|
8
|
+
static getTextures(tile: TiledTileClass, tileSet: TileSet): Texture<import("pixi.js").Resource>[];
|
|
9
9
|
animations: {
|
|
10
10
|
tileid: number;
|
|
11
11
|
duration: number;
|
|
@@ -16,6 +16,6 @@ export default class Tile extends PIXI.AnimatedSprite {
|
|
|
16
16
|
properties: any;
|
|
17
17
|
constructor(tile: TiledTileClass, tileSet: TileSet);
|
|
18
18
|
get gid(): number;
|
|
19
|
-
setAnimation(frame:
|
|
19
|
+
setAnimation(frame: CompositeTilemap): void;
|
|
20
20
|
flip(): void;
|
|
21
21
|
}
|
package/lib/Tilemap/Tile.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AnimatedSprite, groupD8 } from "pixi.js";
|
|
2
|
+
export default class Tile extends AnimatedSprite {
|
|
3
|
+
static getTextures(tile, tileSet) {
|
|
4
|
+
const textures = [];
|
|
5
|
+
if (tile.animations && tile.animations.length) {
|
|
6
|
+
tile.animations.forEach(frame => {
|
|
7
|
+
textures.push(tileSet.textures[frame.tileid].clone());
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
textures.push(tileSet.textures[tile.gid - tileSet.firstgid].clone());
|
|
12
|
+
}
|
|
13
|
+
return textures;
|
|
14
|
+
}
|
|
4
15
|
constructor(tile, tileSet) {
|
|
5
16
|
super(Tile.getTextures(tile, tileSet));
|
|
6
17
|
this.tile = tile;
|
|
@@ -15,18 +26,6 @@ class Tile extends PIXI.AnimatedSprite {
|
|
|
15
26
|
this.texture = this.textures[0];
|
|
16
27
|
this.flip();
|
|
17
28
|
}
|
|
18
|
-
static getTextures(tile, tileSet) {
|
|
19
|
-
const textures = [];
|
|
20
|
-
if (tile.animations && tile.animations.length) {
|
|
21
|
-
tile.animations.forEach(frame => {
|
|
22
|
-
textures.push(tileSet.textures[frame.tileid].clone());
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
textures.push(tileSet.textures[tile.gid - tileSet.firstgid].clone());
|
|
27
|
-
}
|
|
28
|
-
return textures;
|
|
29
|
-
}
|
|
30
29
|
get gid() {
|
|
31
30
|
return this.tile.gid;
|
|
32
31
|
}
|
|
@@ -43,27 +42,26 @@ class Tile extends PIXI.AnimatedSprite {
|
|
|
43
42
|
const add = (symmetrySecond) => {
|
|
44
43
|
i++;
|
|
45
44
|
if (symmetry)
|
|
46
|
-
symmetry =
|
|
45
|
+
symmetry = groupD8.add(symmetry, symmetrySecond);
|
|
47
46
|
else
|
|
48
47
|
symmetry = symmetrySecond;
|
|
49
48
|
};
|
|
50
49
|
if (this.tile.horizontalFlip) {
|
|
51
|
-
add(
|
|
50
|
+
add(groupD8.MIRROR_HORIZONTAL);
|
|
52
51
|
}
|
|
53
52
|
if (this.tile.verticalFlip) {
|
|
54
|
-
add(
|
|
53
|
+
add(groupD8.MIRROR_VERTICAL);
|
|
55
54
|
}
|
|
56
55
|
if (this.tile.diagonalFlip) {
|
|
57
56
|
if (i % 2 == 0) {
|
|
58
|
-
add(
|
|
57
|
+
add(groupD8.MAIN_DIAGONAL);
|
|
59
58
|
}
|
|
60
59
|
else {
|
|
61
|
-
add(
|
|
60
|
+
add(groupD8.REVERSE_DIAGONAL);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
if (symmetry)
|
|
65
64
|
this.texture.rotate = symmetry;
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
|
-
exports.default = Tile;
|
|
69
67
|
//# sourceMappingURL=Tile.js.map
|
package/lib/Tilemap/Tile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tile.js","sourceRoot":"","sources":["../../src/Tilemap/Tile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tile.js","sourceRoot":"","sources":["../../src/Tilemap/Tile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAK3D,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,cAAc;IAC5C,MAAM,CAAC,WAAW,CAAC,IAAoB,EAAE,OAAgB;QACrD,MAAM,QAAQ,GAAc,EAAE,CAAC;QAE/B,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAC3C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC5B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC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KAAK,CAAA;YACnF,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;SAChC;IACL,CAAC;IAED,IAAI;QACA,IAAI,QAAQ,CAAA;QACZ,IAAI,CAAC,GAAC,CAAC,CAAA;QACP,MAAM,GAAG,GAAG,CAAC,cAAc,EAAE,EAAE;YAC3B,CAAC,EAAE,CAAA;YACH,IAAI,QAAQ;gBAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;;gBACzD,QAAQ,GAAG,cAAc,CAAA;QAClC,CAAC,CAAA;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YAC1B,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;SACjC;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACxB,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;SAC/B;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACxB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACZ,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;aAC7B;iBACI;gBACD,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;aAChC;SACJ;QAED,IAAI,QAAQ;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAA;IAEhD,CAAC;CACJ"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { CompositeRectTileLayer } from 'pixi-tilemap';
|
|
2
1
|
import { Layer, Tile as TileClass } from '@rpgjs/tiled';
|
|
3
2
|
import TileSet from './TileSet';
|
|
4
3
|
import TileMap from '.';
|
|
5
4
|
import { CommonLayer } from './CommonLayer';
|
|
6
|
-
export interface RpgRectTileLayer extends CompositeRectTileLayer {
|
|
7
|
-
children: {
|
|
8
|
-
pointsBuf: number[];
|
|
9
|
-
modificationMarker: number;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
12
5
|
export default class TileLayer extends CommonLayer {
|
|
13
6
|
private tileSets;
|
|
14
7
|
private tilemap;
|
package/lib/Tilemap/TileLayer.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const Tile_1 = __importDefault(require("./Tile"));
|
|
7
|
-
const pixi_tilemap_1 = require("pixi-tilemap");
|
|
8
|
-
const CommonLayer_1 = require("./CommonLayer");
|
|
9
|
-
pixi_tilemap_1.pixi_tilemap.Constant.maxTextures = 4;
|
|
10
|
-
pixi_tilemap_1.pixi_tilemap.Constant.use32bitIndex = true;
|
|
11
|
-
class TileLayer extends CommonLayer_1.CommonLayer {
|
|
12
|
-
constructor(layer, tileSets, map) {
|
|
13
|
-
super(layer, map);
|
|
14
|
-
this.tileSets = tileSets;
|
|
15
|
-
this._tiles = {};
|
|
16
|
-
}
|
|
1
|
+
import Tile from './Tile';
|
|
2
|
+
import { CompositeTilemap, settings, POINT_STRUCT_SIZE } from '@pixi/tilemap';
|
|
3
|
+
import { CommonLayer } from './CommonLayer';
|
|
4
|
+
settings.use32bitIndex = true;
|
|
5
|
+
export default class TileLayer extends CommonLayer {
|
|
17
6
|
static findTileSet(gid, tileSets) {
|
|
18
7
|
let tileset;
|
|
19
8
|
for (let i = tileSets.length - 1; i >= 0; i--) {
|
|
@@ -24,9 +13,13 @@ class TileLayer extends CommonLayer_1.CommonLayer {
|
|
|
24
13
|
}
|
|
25
14
|
return tileset;
|
|
26
15
|
}
|
|
16
|
+
constructor(layer, tileSets, map) {
|
|
17
|
+
super(layer, map);
|
|
18
|
+
this.tileSets = tileSets;
|
|
19
|
+
this._tiles = {};
|
|
20
|
+
}
|
|
27
21
|
/** @internal */
|
|
28
22
|
createTile(x, y, options = {}) {
|
|
29
|
-
var _a, _b;
|
|
30
23
|
const { real, filter } = options;
|
|
31
24
|
const { width, tilewidth, tileheight } = this.map.getData();
|
|
32
25
|
if (real) {
|
|
@@ -40,7 +33,7 @@ class TileLayer extends CommonLayer_1.CommonLayer {
|
|
|
40
33
|
const tileset = TileLayer.findTileSet(tiledTile.gid, this.tileSets);
|
|
41
34
|
if (!tileset)
|
|
42
35
|
return;
|
|
43
|
-
const tile = new
|
|
36
|
+
const tile = new Tile(tiledTile, tileset);
|
|
44
37
|
tile.x = x * tilewidth;
|
|
45
38
|
tile.y =
|
|
46
39
|
y * tileheight +
|
|
@@ -49,8 +42,8 @@ class TileLayer extends CommonLayer_1.CommonLayer {
|
|
|
49
42
|
tile._x = x;
|
|
50
43
|
tile._y = y;
|
|
51
44
|
if (tileset.tileoffset) {
|
|
52
|
-
tile.x +=
|
|
53
|
-
tile.y +=
|
|
45
|
+
tile.x += tileset.tileoffset.x ?? 0;
|
|
46
|
+
tile.y += tileset.tileoffset.y ?? 0;
|
|
54
47
|
}
|
|
55
48
|
if (filter) {
|
|
56
49
|
const ret = filter(tile);
|
|
@@ -71,21 +64,25 @@ class TileLayer extends CommonLayer_1.CommonLayer {
|
|
|
71
64
|
}
|
|
72
65
|
else {
|
|
73
66
|
if (newTile) {
|
|
74
|
-
const bufComposite = new
|
|
75
|
-
const frame = bufComposite.
|
|
67
|
+
const bufComposite = new CompositeTilemap();
|
|
68
|
+
const frame = bufComposite.tile(newTile.texture, newTile.x, newTile.y);
|
|
76
69
|
newTile.setAnimation(frame);
|
|
77
70
|
this._tiles[x + ';' + y] = newTile;
|
|
71
|
+
// @ts-ignore
|
|
78
72
|
const pointsBufComposite = bufComposite.children[0].pointsBuf;
|
|
79
|
-
[0, 1, 4,
|
|
73
|
+
[0, 1, 4, 6, 7, 8].forEach((i) => {
|
|
80
74
|
if (this.pointsBuf)
|
|
81
75
|
this.pointsBuf[oldTile.pointsBufIndex + i] = pointsBufComposite[i];
|
|
82
76
|
});
|
|
77
|
+
// @ts-ignore
|
|
83
78
|
this.tilemap.children[0].modificationMarker = 0;
|
|
79
|
+
this.addFrame(newTile, x, y);
|
|
80
|
+
this['modificationMarker'] = 0;
|
|
84
81
|
}
|
|
85
82
|
else {
|
|
86
83
|
delete this._tiles[x + ';' + y];
|
|
87
84
|
if (this.pointsBuf)
|
|
88
|
-
this.pointsBuf.splice(oldTile.pointsBufIndex,
|
|
85
|
+
this.pointsBuf.splice(oldTile.pointsBufIndex, POINT_STRUCT_SIZE);
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
}
|
|
@@ -94,20 +91,22 @@ class TileLayer extends CommonLayer_1.CommonLayer {
|
|
|
94
91
|
const child = this.tilemap.children[0];
|
|
95
92
|
if (!child)
|
|
96
93
|
return null;
|
|
97
|
-
return child
|
|
94
|
+
return child['pointsBuf'];
|
|
98
95
|
}
|
|
99
96
|
addFrame(tile, x, y) {
|
|
100
|
-
const frame = this.tilemap.
|
|
97
|
+
const frame = this.tilemap.tile(tile.texture, tile.x, tile.y, {
|
|
98
|
+
rotate: tile.texture.rotate
|
|
99
|
+
});
|
|
101
100
|
const pb = this.pointsBuf;
|
|
102
101
|
if (!pb)
|
|
103
102
|
return null;
|
|
104
|
-
tile.pointsBufIndex = pb.length -
|
|
103
|
+
tile.pointsBufIndex = pb.length - POINT_STRUCT_SIZE;
|
|
105
104
|
tile.setAnimation(frame);
|
|
106
105
|
this._tiles[x + ';' + y] = tile;
|
|
107
106
|
}
|
|
108
107
|
/** @internal */
|
|
109
108
|
create() {
|
|
110
|
-
this.tilemap = new
|
|
109
|
+
this.tilemap = new CompositeTilemap();
|
|
111
110
|
const { width, height } = this.map.getData();
|
|
112
111
|
for (let y = 0; y < height; y++) {
|
|
113
112
|
for (let x = 0; x < width; x++) {
|
|
@@ -120,5 +119,4 @@ class TileLayer extends CommonLayer_1.CommonLayer {
|
|
|
120
119
|
this.addChild(this.tilemap);
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
|
-
exports.default = TileLayer;
|
|
124
122
|
//# sourceMappingURL=TileLayer.js.map
|