Skip to content

Commit f303996

Browse files
committed
Removed ability to set alpha per animation frame (you do it via onUpdate if needed)
Added showOnStart and hideOnComplete config options to set visible state of sprite.
1 parent e462def commit f303996

7 files changed

Lines changed: 29 additions & 22 deletions

File tree

v3/src/animation/AnimationFrame.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ var AnimationFrame = function (index, frame)
2424
// Callback if this frame gets displayed
2525
this.onUpdate = null;
2626

27-
// When this frame hits, set sprite.alpha to this
28-
this.setAlpha = false;
29-
this.alpha = 1;
30-
3127
// When this frame hits, set sprite.visible to this
3228
this.setVisible = false;
3329
this.visible = false;

v3/src/animation/AnimationManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ AnimationManager.prototype = {
4646
// { key: textureKey, frame: textureFrame },
4747
// { key: textureKey, frame: textureFrame, duration: float },
4848
// { key: textureKey, frame: textureFrame, onUpdate: function }
49-
// { key: textureKey, frame: textureFrame, alpha: float }
5049
// { key: textureKey, frame: textureFrame, visible: boolean }
5150
// ]
5251
// framerate: integer
@@ -56,6 +55,7 @@ AnimationManager.prototype = {
5655
// repeat: -1 = forever, otherwise integer
5756
// repeatDelay: integer
5857
// yoyo: boolean
58+
// showOnStart: boolean
5959
// hideOnComplete: boolean
6060
// onStart: function
6161
// onRepeat: function

v3/src/animation/frame/Animation.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ var Animation = function (manager, key, config)
5555
// Should the animation yoyo? (reverse back down to the start) before repeating?
5656
this.yoyo = GetObjectValue(config, 'yoyo', false);
5757

58+
// Should sprite.visible = true when the animation starts to play?
59+
this.showOnStart = GetObjectValue(config, 'showOnStart', false);
60+
61+
// Should sprite.visible = false when the animation finishes?
62+
this.hideOnComplete = GetObjectValue(config, 'hideOnComplete', false);
63+
5864
// Callbacks (swap for Events?)
5965
this.onStart = GetObjectValue(config, 'onStart', false);
6066
this.onRepeat = GetObjectValue(config, 'onRepeat', false);
@@ -144,8 +150,7 @@ Animation.prototype = {
144150
}
145151
else
146152
{
147-
// OnComplete
148-
component.stop();
153+
this.completeAnimation(component);
149154
}
150155
}
151156
else
@@ -173,8 +178,7 @@ Animation.prototype = {
173178
}
174179
else
175180
{
176-
// OnComplete
177-
component.stop();
181+
this.completeAnimation(component);
178182
}
179183
}
180184
else
@@ -209,6 +213,19 @@ Animation.prototype = {
209213
}
210214
},
211215

216+
completeAnimation: function (component)
217+
{
218+
component.stop();
219+
220+
if (this.hideOnComplete)
221+
{
222+
component.parent.visible = false;
223+
}
224+
225+
// Events
226+
227+
},
228+
212229
setFrame: function (component)
213230
{
214231
// Work out which frame should be set next on the child, and set it

v3/src/animation/frame/GetFrames.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var GetFrames = function (textureManager, frames)
77
// { key: textureKey, frame: textureFrame },
88
// { key: textureKey, frame: textureFrame, duration: float },
99
// { key: textureKey, frame: textureFrame, onUpdate: function }
10+
// { key: textureKey, frame: textureFrame, visible: boolean }
1011
// ],
1112

1213
// console.table(frames);
@@ -31,7 +32,6 @@ var GetFrames = function (textureManager, frames)
3132
var frame = GetObjectValue(item, 'frame', 0);
3233
var duration = GetObjectValue(item, 'duration', 0);
3334
var onUpdate = GetObjectValue(item, 'onUpdate', null);
34-
var alpha = GetObjectValue(item, 'alpha', null);
3535
var visible = GetObjectValue(item, 'visible', null);
3636

3737
var textureFrame = textureManager.getFrame(key, frame);
@@ -41,12 +41,6 @@ var GetFrames = function (textureManager, frames)
4141
animationFrame.duration = duration;
4242
animationFrame.onUpdate = onUpdate;
4343

44-
if (alpha !== null)
45-
{
46-
animationFrame.setAlpha = true;
47-
animationFrame.alpha = alpha;
48-
}
49-
5044
if (visible !== null)
5145
{
5246
animationFrame.setVisible = true;

v3/src/animation/frame/Play.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ var Play = function (key, startFrame)
1515

1616
this.prevTick = this.mainloop.lastFrameTimeMs;
1717

18+
if (currentAnim.showOnStart)
19+
{
20+
this.parent.visible = true;
21+
}
22+
1823
return this;
1924
};
2025

v3/src/animation/frame/UpdateFrame.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ var UpdateFrame = function (animationFrame)
1212
sprite.alpha = animationFrame.alpha;
1313
}
1414

15-
if (animationFrame.setVisible)
16-
{
17-
sprite.visible = animationFrame.visible;
18-
}
19-
2015
if (animationFrame.onUpdate)
2116
{
2217
animationFrame.onUpdate(sprite, animationFrame);

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: '1fc4c990-1bf4-11e7-a52f-5f7dcf3f36ad'
2+
build: 'e6996440-1de8-11e7-bd97-cdf675a0abb1'
33
};
44
module.exports = CHECKSUM;

0 commit comments

Comments
 (0)