mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Graphics Game Object base
This commit is contained in:
parent
13810cb601
commit
c30a95cb01
8 changed files with 78 additions and 3 deletions
27
v3/src/gameobjects/graphics/Graphics.js
Normal file
27
v3/src/gameobjects/graphics/Graphics.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var GameObject = require('../GameObject');
|
||||
var Components = require('../../components');
|
||||
var Render = require('./GraphicsRender');
|
||||
|
||||
var Graphics = new Class({
|
||||
|
||||
Mixins: [
|
||||
Components.Alpha,
|
||||
Components.BlendMode,
|
||||
Components.Transform,
|
||||
Components.Visible,
|
||||
Render
|
||||
],
|
||||
|
||||
initialize:
|
||||
|
||||
function Graphics (state, x, y)
|
||||
{
|
||||
GameObject.call(this, state);
|
||||
|
||||
this.setPosition(x, y);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Graphics;
|
9
v3/src/gameobjects/graphics/GraphicsCanvasRenderer.js
Normal file
9
v3/src/gameobjects/graphics/GraphicsCanvasRenderer.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
{
|
||||
if (this.renderMask !== this.renderFlags)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GraphicsCanvasRenderer;
|
22
v3/src/gameobjects/graphics/GraphicsFactory.js
Normal file
22
v3/src/gameobjects/graphics/GraphicsFactory.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
var Graphics = require('./Graphics');
|
||||
var FactoryContainer = require('../../gameobjects/FactoryContainer');
|
||||
|
||||
var GraphicsFactory = {
|
||||
|
||||
KEY: 'graphics',
|
||||
|
||||
add: function (x, y, group)
|
||||
{
|
||||
if (group === undefined) { group = this.state; }
|
||||
|
||||
return group.children.add(new Graphics(this.state, x, y));
|
||||
},
|
||||
|
||||
make: function (x, y)
|
||||
{
|
||||
return new Graphics(this.state, x, y);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = FactoryContainer.register(GraphicsFactory);
|
6
v3/src/gameobjects/graphics/GraphicsRender.js
Normal file
6
v3/src/gameobjects/graphics/GraphicsRender.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
|
||||
renderCanvas: require('./GraphicsCanvasRenderer'),
|
||||
renderWebGL: require('./GraphicsWebGLRenderer')
|
||||
|
||||
};
|
9
v3/src/gameobjects/graphics/GraphicsWebGLRenderer.js
Normal file
9
v3/src/gameobjects/graphics/GraphicsWebGLRenderer.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
{
|
||||
if (this.renderMask !== this.renderFlags)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GraphicsWebGLRenderer;
|
|
@ -6,6 +6,7 @@ require('./container/ContainerFactory');
|
|||
require('./image/ImageFactory');
|
||||
require('./sprite/SpriteFactory');
|
||||
require('./text/BitmapTextFactory');
|
||||
require('./graphics/GraphicsFactory');
|
||||
|
||||
// Phaser.GameObjects
|
||||
|
||||
|
@ -17,6 +18,7 @@ module.exports = {
|
|||
Blitter: require('./blitter/Blitter'),
|
||||
Container: require('./container/Container'),
|
||||
Image: require('./image/Image'),
|
||||
Sprite: require('./sprite/Sprite')
|
||||
Sprite: require('./sprite/Sprite'),
|
||||
Graphics: require('./graphics/Graphics.js')
|
||||
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var GameObject = require('../GameObject');
|
||||
var Components = require('../../components');
|
||||
var Renderer = require('./BitmapTextRenderer');
|
||||
var Render = require('./BitmapTextRender');
|
||||
|
||||
var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ var BitmapText = new Class({
|
|||
Components.Alpha,
|
||||
Components.BlendMode,
|
||||
Components.Visible,
|
||||
Renderer
|
||||
Render
|
||||
],
|
||||
|
||||
initialize:
|
||||
|
|
Loading…
Reference in a new issue