Skip to content

Commit 129a045

Browse files
committed
Start of Quad class.
1 parent d1468bb commit 129a045

6 files changed

Lines changed: 142 additions & 7 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '79ec29b0-3b8c-11e7-abc1-aba9f8e0478d'
2+
build: '5246eae0-3cc6-11e7-a401-c3d2fac692e5'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require('./effectlayer/EffectLayerFactory');
1515
require('./renderpass/RenderPassFactory');
1616
require('./tilesprite/TileSpriteFactory');
1717
require('./mesh/MeshFactory');
18+
require('./quad/QuadFactory');
1819

1920
// Phaser.GameObjects
2021

@@ -35,6 +36,7 @@ module.exports = {
3536
Text: require('./text/static/Text'),
3637
Zone: require('./zone/Zone'),
3738
EffectLayer: require('./effectlayer/EffectLayer'),
38-
Mesh: require('./mesh/Mesh')
39+
Mesh: require('./mesh/Mesh'),
40+
Quad: require('./quad/Quad')
3941

4042
};
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
var MeshCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
22
{
3-
if (this.renderMask !== this.renderFlags)
4-
{
5-
return;
6-
}
73
};
84

9-
module.exports = MeshCanvasRenderer
5+
module.exports = MeshCanvasRenderer;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var Quad = require('./Quad');
2+
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
3+
var GetValue = require('../../utils/object/GetValue');
4+
var BuildGameObject = require('../BuildGameObject');
5+
6+
var BuildFromConfig = function (state, config)
7+
{
8+
var key = GetAdvancedValue(config, 'key', null);
9+
var frame = GetAdvancedValue(config, 'frame', null);
10+
var vertices = GetValue(config, 'vertices', []);
11+
var indices = GetValue(config, 'indices', []);
12+
var uv = GetValue(config, 'uv', []);
13+
14+
var quad = new Quad(state, 0, 0, vertices, uv, indices, key, frame);
15+
16+
BuildGameObject(state, quad, config);
17+
18+
return quad;
19+
};
20+
21+
module.exports = BuildFromConfig;

v3/src/gameobjects/quad/Quad.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
var Class = require('../../utils/Class');
3+
var Mesh = require('../mesh/Mesh');
4+
5+
var Quad = new Class({
6+
7+
Extends: Mesh,
8+
9+
initialize:
10+
11+
function Quad (state, x, y, texture, frame)
12+
{
13+
// 0----3
14+
// |\ B|
15+
// | \ |
16+
// | \ |
17+
// | A \|
18+
// | \
19+
// 1----2
20+
21+
// var topLeft = { x: -250, y: -250 };
22+
var topRight = { x: 250, y: -250 };
23+
var bottomLeft = { x: -250, y: 250 };
24+
var bottomRight = { x: 250, y: 250 };
25+
26+
// tl, bl, br, tr
27+
var vertices = [
28+
0, 0,
29+
bottomLeft.x, bottomLeft.y,
30+
bottomRight.x, bottomRight.y,
31+
topRight.x, topRight.y
32+
];
33+
34+
var uv = [ 0, 0, 0, 1, 1, 1, 1, 0 ];
35+
var indices = [ 0, 1, 2, 0, 2, 3 ];
36+
37+
Mesh.call(this, state, x, y, vertices, uv, indices, texture, frame);
38+
39+
this.halfWidth = Math.floor(this.width / 2);
40+
this.halfHeight = Math.floor(this.height / 2);
41+
42+
this._topLeft = { x: 0, y: 0 };
43+
this._topRight = { x: 250, y: -250 };
44+
this._bottomLeft = { x: -250, y: 250 };
45+
this._bottomRight = { x: 250, y: 250 };
46+
47+
this.setTopLeft(this.halfWidth, this.halfHeight);
48+
49+
// var v = this.vertices;
50+
51+
// v[0] = -w;
52+
// v[1] = -h;
53+
// v[1] = -h;
54+
},
55+
56+
topLeftX: {
57+
58+
get: function ()
59+
{
60+
return this._topLeft.x;
61+
},
62+
63+
set: function (value)
64+
{
65+
this._topLeft.x = value;
66+
this.vertices[0] = value - this.x;
67+
}
68+
69+
},
70+
71+
topLeftY: {
72+
73+
get: function ()
74+
{
75+
return this._topLeft.y;
76+
},
77+
78+
set: function (value)
79+
{
80+
this._topLeft.y = value;
81+
this.vertices[1] = value - this.y;
82+
}
83+
84+
},
85+
86+
setTopLeft: function (x, y)
87+
{
88+
this.topLeftX = x;
89+
this.topLeftY = y;
90+
}
91+
92+
});
93+
94+
module.exports = Quad;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
var Quad = require('./Quad');
3+
var BuildFromConfig = require('./BuildFromConfig');
4+
var FactoryContainer = require('../../gameobjects/FactoryContainer');
5+
6+
var QuadFactory = {
7+
8+
KEY: 'quad',
9+
10+
add: function (x, y, key, frame)
11+
{
12+
return this.children.add(new Quad(this.state, x, y, key, frame));
13+
},
14+
15+
make: function (config)
16+
{
17+
return BuildFromConfig(this.state, config);
18+
}
19+
20+
};
21+
22+
module.exports = FactoryContainer.register(QuadFactory);

0 commit comments

Comments
 (0)