BitmapText work in progress

This commit is contained in:
Felipe Alfonso 2017-02-23 15:18:01 -03:00
parent c88749af98
commit 618e47c103
6 changed files with 89 additions and 0 deletions

View file

@ -4,6 +4,7 @@
require('./image/ImageFactory');
require('./sprite/SpriteFactory');
require('./blitter/BlitterFactory');
require('./text/BitmapTextFactory');
// require('./gameobjects/container/ContainerFactory');

View file

@ -0,0 +1,34 @@
var Class = require('../../utils/Class');
var GameObject = require('../GameObject');
var Components = require('../../components');
var Renderer = require('./BitmapTextRenderer')
var BitmapText = new Class({
Mixins: [
Components.Transform,
Components.Texture,
Components.Size,
Components.Alpha,
Components.BlendMode,
Components.ScaleMode,
Components.Visible,
Renderer
],
initialize:
function BitmapText (state, x, y, key, text)
{
GameObject.call(this, state);
this.text = typeof text === 'string' ? text : '';
this.fontData = this.state.sys.cache.xml.get(key);
this.setTexture(key, null);
this.setPosition(x, y);
}
});
module.exports = BitmapText;

View file

@ -0,0 +1,6 @@
var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
{
};
module.exports = BitmapTextCanvasRenderer;

View file

@ -0,0 +1,22 @@
var BitmapText = require('./BitmapText');
var FactoryContainer = require('../../gameobjects/FactoryContainer');
var BitmapTextFactory = {
KEY: 'bitmapText',
add: function (x, y, key, text, group)
{
if (group === undefined) { group = this.state; }
return group.children.add(new BitmapText(this.state, x, y, key, text));
},
make: function (x, y, key, text)
{
return new BitmapText(this.state, x, y, key, text);
}
};
module.exports = FactoryContainer.register(BitmapTextFactory);

View file

@ -0,0 +1,6 @@
module.exports = {
renderCanvas: require('./BitmapTextCanvasRenderer'),
renderWebGL: require('./BitmapTextWebGLRenderer')
};

View file

@ -0,0 +1,20 @@
var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
{
if (this.renderMask !== this.renderFlags)
{
return;
}
var blitterBatch = renderer.blitterBatch;
var cameraMatrix = camera.matrix.matrix;
var a = cameraMatrix[0];
var b = cameraMatrix[1];
var c = cameraMatrix[2];
var d = cameraMatrix[3];
var e = cameraMatrix[4];
var f = cameraMatrix[5];
var cameraScrollX = camera.scrollX;
var cameraScrollY = camera.scrollY;
};
module.exports = BitmapTextWebGLRenderer;