Fixed sounds spamming on last frame.
This commit is contained in:
parent
3d71fcbc70
commit
c6b1d9089c
1 changed files with 6 additions and 3 deletions
|
@ -497,13 +497,15 @@ module.exports = Surface = class Surface extends CocoClass
|
||||||
# seems to be a bug where only one object can register with the Ticker...
|
# seems to be a bug where only one object can register with the Ticker...
|
||||||
oldFrame = @currentFrame
|
oldFrame = @currentFrame
|
||||||
oldWorldFrame = Math.floor oldFrame
|
oldWorldFrame = Math.floor oldFrame
|
||||||
|
lastFrame = @world.totalFrames - 1
|
||||||
while true
|
while true
|
||||||
Dropper.tick()
|
Dropper.tick()
|
||||||
@trailmaster.tick() if @trailmaster
|
@trailmaster.tick() if @trailmaster
|
||||||
# Skip some frame updates unless we're playing and not at end (or we haven't drawn much yet)
|
# Skip some frame updates unless we're playing and not at end (or we haven't drawn much yet)
|
||||||
frameAdvanced = (@playing and @currentFrame < @world.totalFrames) or @totalFramesDrawn < 2
|
frameAdvanced = (@playing and @currentFrame < lastFrame) or @totalFramesDrawn < 2
|
||||||
@currentFrame += @world.frameRate / @options.frameRate if frameAdvanced and @playing
|
if frameAdvanced and @playing
|
||||||
@currentFrame = Math.min(@currentFrame, @world.totalFrames - 1)
|
@currentFrame += @world.frameRate / @options.frameRate
|
||||||
|
@currentFrame = Math.min @currentFrame, lastFrame
|
||||||
newWorldFrame = Math.floor @currentFrame
|
newWorldFrame = Math.floor @currentFrame
|
||||||
worldFrameAdvanced = newWorldFrame isnt oldWorldFrame
|
worldFrameAdvanced = newWorldFrame isnt oldWorldFrame
|
||||||
if worldFrameAdvanced
|
if worldFrameAdvanced
|
||||||
|
@ -513,6 +515,7 @@ module.exports = Surface = class Surface extends CocoClass
|
||||||
break unless Dropper.drop()
|
break unless Dropper.drop()
|
||||||
if frameAdvanced and not worldFrameAdvanced
|
if frameAdvanced and not worldFrameAdvanced
|
||||||
# We didn't end the above loop on an integer frame, so do the world state update.
|
# We didn't end the above loop on an integer frame, so do the world state update.
|
||||||
|
console.log "Restore world state"
|
||||||
@restoreWorldState()
|
@restoreWorldState()
|
||||||
|
|
||||||
# these are skipped for dropped frames
|
# these are skipped for dropped frames
|
||||||
|
|
Reference in a new issue