Fixed some bugs with sprite sound loading and playback.

This commit is contained in:
Nick Winter 2014-05-15 20:49:10 -07:00
parent 65aae86dcc
commit ca6ea474bf
2 changed files with 12 additions and 10 deletions

View file

@ -80,6 +80,8 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
@listenToOnce(@thangType, 'sync', @setupSprite) @listenToOnce(@thangType, 'sync', @setupSprite)
setupSprite: -> setupSprite: ->
for trigger, sounds of @thangType.get('soundTriggers') or {} when trigger isnt 'say'
AudioPlayer.preloadSoundReference sound for sound in sounds
@stillLoading = false @stillLoading = false
if @thangType.get('raster') if @thangType.get('raster')
@isRaster = true @isRaster = true
@ -674,7 +676,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
delay = if withDelay and sound.delay then 1000 * sound.delay / createjs.Ticker.getFPS() else 0 delay = if withDelay and sound.delay then 1000 * sound.delay / createjs.Ticker.getFPS() else 0
name = AudioPlayer.nameForSoundReference sound name = AudioPlayer.nameForSoundReference sound
instance = AudioPlayer.playSound name, volume, delay, @getWorldPosition() instance = AudioPlayer.playSound name, volume, delay, @getWorldPosition()
# console.log @thang?.id, "played sound", name, "with delay", delay, "volume", volume, "and got sound instance", instance #console.log @thang?.id, "played sound", name, "with delay", delay, "volume", volume, "and got sound instance", instance
instance instance
onMove: (e) -> onMove: (e) ->

View file

@ -272,7 +272,7 @@ module.exports = class SpriteBoss extends CocoClass
@selectedSprite?.selected = false @selectedSprite?.selected = false
sprite?.selected = true sprite?.selected = true
@selectedSprite = sprite @selectedSprite = sprite
alive = sprite?.thang.health > 0 alive = not (sprite?.thang.health < 0)
Backbone.Mediator.publish 'surface:sprite-selected', Backbone.Mediator.publish 'surface:sprite-selected',
thang: if sprite then sprite.thang else null thang: if sprite then sprite.thang else null