Browse Source

work

1870-zone-sprite-atlas
Shaun 2 years ago
parent
commit
cf8568f723
3 changed files with 80 additions and 0 deletions
  1. +56
    -0
      src/server/clientComponents/textSprite.js
  2. +20
    -0
      src/server/components/textSprite.js
  3. +4
    -0
      src/server/world/map/builders/object.js

+ 56
- 0
src/server/clientComponents/textSprite.js View File

@@ -0,0 +1,56 @@
define([
'js/rendering/renderer'
], function (
renderer
) {
return {
type: 'textSprite',

text: null,
layerName: null,

sprite: undefined,

init: function (blueprint) {
this.buildSprite();
},

buildSprite: async function () {
const { layerName, text, parent: container } = this;

this.sprite = renderer.buildText({
layerName,
text
});
},

update: function () {
const { sprite, obj } = this;

if (!sprite)
return;

Object.entries({
x: (obj.x * scale) + (obj.offsetX || 0),
y: (obj.y * scale) + (obj.offsetY || 0),
visible: obj.isVisible
}).forEach(([k, v]) => {
if (sprite[k] !== v && v !== undefined)
sprite[k] = v;
});

[
'text'
].forEach(p => {
const value = this[p];

if (sprite[p] !== value && value !== undefined)
sprite[p] = value;
});
},

destroy: function () {
}
};
});

+ 20
- 0
src/server/components/textSprite.js View File

@@ -0,0 +1,20 @@
module.exports = {
type: 'textSprite',

text: 'test text, please ignore',
layerName: 'effects',

init: function (blueprint) {
this.text = blueprint.text;
},

simplify: function (self) {
const { text, layerName } = this;

return {
type: 'textSprite',
text,
layerName
};
}
};

+ 4
- 0
src/server/world/map/builders/object.js View File

@@ -123,6 +123,10 @@ const buildObject = (mapModule, layerName, mapObj) => {
sheetName: blueprint.sheetName
};

blueprint.properties.cpnTextSprite = {
text: blueprint.name
};

delete blueprint.sheetName;
delete blueprint.cell;
}


Loading…
Cancel
Save