mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
BitmapText work in progress
This commit is contained in:
parent
c88749af98
commit
618e47c103
6 changed files with 89 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
require('./image/ImageFactory');
|
require('./image/ImageFactory');
|
||||||
require('./sprite/SpriteFactory');
|
require('./sprite/SpriteFactory');
|
||||||
require('./blitter/BlitterFactory');
|
require('./blitter/BlitterFactory');
|
||||||
|
require('./text/BitmapTextFactory');
|
||||||
|
|
||||||
// require('./gameobjects/container/ContainerFactory');
|
// require('./gameobjects/container/ContainerFactory');
|
||||||
|
|
||||||
|
|
34
v3/src/gameobjects/text/BitmapText.js
Normal file
34
v3/src/gameobjects/text/BitmapText.js
Normal 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;
|
6
v3/src/gameobjects/text/BitmapTextCanvasRenderer.js
Normal file
6
v3/src/gameobjects/text/BitmapTextCanvasRenderer.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = BitmapTextCanvasRenderer;
|
22
v3/src/gameobjects/text/BitmapTextFactory.js
Normal file
22
v3/src/gameobjects/text/BitmapTextFactory.js
Normal 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);
|
6
v3/src/gameobjects/text/BitmapTextRenderer.js
Normal file
6
v3/src/gameobjects/text/BitmapTextRenderer.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
renderCanvas: require('./BitmapTextCanvasRenderer'),
|
||||||
|
renderWebGL: require('./BitmapTextWebGLRenderer')
|
||||||
|
|
||||||
|
};
|
20
v3/src/gameobjects/text/BitmapTextWebGLRenderer.js
Normal file
20
v3/src/gameobjects/text/BitmapTextWebGLRenderer.js
Normal 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;
|
Loading…
Reference in a new issue