Skip to content

Commit db55c4c

Browse files
committed
Added new Zone game object.
1 parent 6d6af08 commit db55c4c

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

v3/src/gameobjects/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require('./bitmaptext/dynamic/DynamicBitmapTextFactory');
1010
require('./graphics/GraphicsFactory');
1111
require('./text/static/TextFactory');
1212
require('./layer/LayerFactory');
13+
require('./zone/ZoneFactory');
1314

1415
// Phaser.GameObjects
1516

@@ -23,8 +24,9 @@ module.exports = {
2324
DynamicBitmapText: require('./bitmaptext/dynamic/DynamicBitmapText'),
2425
Graphics: require('./graphics/Graphics.js'),
2526
Image: require('./image/Image'),
27+
Layer: require('./layer/Layer'),
2628
Sprite: require('./sprite/Sprite'),
2729
Text: require('./text/static/Text'),
28-
Layer: require('./layer/Layer')
30+
Zone: require('./zone/Zone')
2931

3032
};

v3/src/gameobjects/zone/Zone.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
var Class = require('../../utils/Class');
3+
var GameObject = require('../GameObject');
4+
var Components = require('../../components');
5+
6+
var Zone = new Class({
7+
8+
Mixins: [
9+
Components.GetBounds,
10+
Components.Origin,
11+
Components.ScaleMode,
12+
Components.Size,
13+
Components.Transform,
14+
Components.Visible
15+
],
16+
17+
initialize:
18+
19+
function Zone (state, x, y, width, height)
20+
{
21+
GameObject.call(this, state);
22+
23+
this.setPosition(x, y);
24+
this.setSize(width, height);
25+
this.setOrigin(0);
26+
}
27+
28+
});
29+
30+
module.exports = Zone;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var Zone = require('./Zone');
2+
var FactoryContainer = require('../../gameobjects/FactoryContainer');
3+
4+
var ZoneFactory = {
5+
6+
KEY: 'zone',
7+
8+
add: function (x, y, width, height)
9+
{
10+
return new Zone(this.state, x, y, width, height);
11+
},
12+
13+
make: function (x, y, width, height)
14+
{
15+
return new Zone(this.state, x, y, width, height);
16+
}
17+
18+
};
19+
20+
module.exports = FactoryContainer.register(ZoneFactory);

0 commit comments

Comments
 (0)