Skip to content

Commit 4684d23

Browse files
committed
Linting fixes.
1 parent f125f35 commit 4684d23

2 files changed

Lines changed: 59 additions & 21 deletions

File tree

v3/src/animation/AnimationManager.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7-
// var Parser = require('./parsers');
8-
// var Texture = require('./Texture');
9-
// var CanvasPool = require('../dom/CanvasPool');
7+
var Map = require('../structs/Map');
108

119
/**
1210
* Animations are managed by the global AnimationManager. This is a singleton class that is
@@ -23,7 +21,7 @@ var AnimationManager = function (game)
2321
{
2422
this.game = game;
2523

26-
this.list = {};
24+
this.anims = new Map();
2725
};
2826

2927
AnimationManager.prototype.constructor = AnimationManager;
@@ -37,15 +35,18 @@ AnimationManager.prototype = {
3735

3836
add: function (key, frames, loop)
3937
{
38+
if (this.anims.has(key))
39+
{
40+
console.error('Animation with key', key, 'already exists');
41+
return;
42+
}
43+
4044

4145
},
4246

4347
get: function (key)
4448
{
45-
if (this.list[key])
46-
{
47-
//
48-
}
49+
return this.anims.get(key);
4950
}
5051

5152
};

v3/src/gameobjects/layer/Layer.js

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ var Layer = new Class({
55

66
initialize:
77

8-
function Layer()
8+
function Layer ()
99
{
1010
this.children = [];
11+
1112
Array.prototype.push.apply(this.children, arguments);
1213
},
1314

14-
add: function (child)
15+
add: function (child)
1516
{
1617
var children = this.children;
1718
var index = children.indexOf(child);
@@ -20,103 +21,139 @@ var Layer = new Class({
2021
{
2122
children.push(child);
2223
}
24+
25+
return this;
2326
},
2427

2528
addArray: function (childrenArray)
2629
{
2730
var length = childrenArray.length;
31+
2832
for (var index = 0; index < length; ++index)
2933
{
3034
this.add(childrenArray[index]);
3135
}
36+
37+
return this;
3238
},
3339

34-
addX: function (value) {
40+
addX: function (value)
41+
{
3542
var children = this.children;
3643
var length = children.length;
44+
3745
for (var index = 0; index < length; ++index)
3846
{
3947
children[index].x += value;
4048
}
49+
50+
return this;
4151
},
4252

43-
addY: function (value)
53+
addY: function (value)
4454
{
4555
var children = this.children;
4656
var length = children.length;
4757
for (var index = 0; index < length; ++index)
4858
{
4959
children[index].y += value;
5060
}
61+
62+
return this;
5163
},
5264

53-
addPosition: function (x, y)
65+
addPosition: function (x, y)
5466
{
5567
var children = this.children;
5668
var length = children.length;
69+
5770
for (var index = 0; index < length; ++index)
5871
{
5972
children[index].x += x;
6073
children[index].y += y;
6174
}
75+
76+
return this;
6277
},
6378

64-
rotate: function (value) {
79+
rotate: function (value)
80+
{
6581
var children = this.children;
6682
var length = children.length;
83+
6784
for (var index = 0; index < length; ++index)
6885
{
6986
children[index].rotation += value;
7087
}
88+
89+
return this;
7190
},
7291

73-
setX: function (value) {
92+
setX: function (value)
93+
{
7494
var children = this.children;
7595
var length = children.length;
96+
7697
for (var index = 0; index < length; ++index)
7798
{
7899
children[index].x = value;
79100
}
101+
102+
return this;
80103
},
81104

82-
setY: function (value)
105+
setY: function (value)
83106
{
84107
var children = this.children;
85108
var length = children.length;
109+
86110
for (var index = 0; index < length; ++index)
87111
{
88112
children[index].y = value;
89113
}
114+
115+
return this;
90116
},
91117

92-
setRotation: function (value) {
118+
setRotation: function (value)
119+
{
93120
var children = this.children;
94121
var length = children.length;
122+
95123
for (var index = 0; index < length; ++index)
96124
{
97125
children[index].rotation = value;
98126
}
127+
128+
return this;
99129
},
100130

101-
setVisible: function (value) {
131+
setVisible: function (value)
132+
{
102133
var children = this.children;
103134
var length = children.length;
135+
104136
for (var index = 0; index < length; ++index)
105137
{
106138
children[index].visible = value;
107-
}
139+
}
140+
141+
return this;
108142
},
109143

110144
toggleVisible: function ()
111145
{
112146
var children = this.children;
113147
var length = children.length;
148+
114149
for (var index = 0; index < length; ++index)
115150
{
116151
children[index].visible = !children[index].visible;
117-
}
152+
}
153+
154+
return this;
118155
}
119156

120157
});
121158

122-
module.exports = Layer;
159+
module.exports = Layer;

0 commit comments

Comments
 (0)