This commit is contained in:
Scott Erickson 2014-02-24 19:49:12 -08:00
commit 168f268d21
4 changed files with 25 additions and 16 deletions

View file

@ -48,7 +48,7 @@ module.exports = class Mark extends CocoClass
build: ->
unless @mark
if @name is 'bounds' then @buildBounds()
else if @name is 'shadow' then @buildRadius()
else if @name is 'shadow' then @buildShadow()
else if @name is 'debug' then @buildDebug()
else if @thangType then @buildSprite()
else console.error "Don't know how to build mark for", @name
@ -87,21 +87,31 @@ module.exports = class Mark extends CocoClass
@lastWidth = @sprite.thang.width
@lastHeight = @sprite.thang.height
buildRadius: ->
# TODO: make this not just a shadow
# TODO: draw boxes and ellipses for non-circular Thangs
diameter = @sprite.thangType.get('shadow') ? @sprite.thang?.width + 0.5
diameter *= Camera.PPM
buildShadow: ->
width = (@sprite.thang?.width ? 0) + 0.5
height = (@sprite.thang?.height ? 0) + 0.5
longest = Math.max width, height
actualLongest = @sprite.thangType.get('shadow') ? longest
width = width * actualLongest / longest
height = height * actualLongest / longest
width *= Camera.PPM
height *= Camera.PPM * @camera.y2x # TODO: doesn't work with rotation
@mark = new createjs.Shape()
@mark.mouseEnabled = false
@mark.graphics.beginFill "black"
@mark.graphics.drawEllipse 0, 0, diameter, diameter * @camera.y2x
if @sprite.thang.shape in ['ellipsoid', 'disc']
@mark.graphics.drawEllipse 0, 0, width, height
else
@mark.graphics.drawRect 0, 0, width, height
@mark.graphics.endFill()
@mark.regX = diameter / 2
@mark.regY = diameter / 2 * @camera.y2x
@mark.regX = width / 2
@mark.regY = height / 2
@mark.layerIndex = 10
#@mark.cache 0, 0, diameter, diameter # not actually faster than simple ellipse draw
buildRadius: ->
return # not implemented
buildDebug: ->
@mark = new createjs.Shape()
PX = 3
@ -152,7 +162,7 @@ module.exports = class Mark extends CocoClass
@mark.y += offset.y
updateRotation: ->
if @name is 'debug'
if @name is 'debug' or (@name is 'shadow' and @sprite.thang?.shape in ["rectangle", "box"])
@mark.rotation = @sprite.thang.rotation * 180 / Math.PI
updateScale: ->
@ -177,4 +187,3 @@ module.exports = class Mark extends CocoClass
stop: -> @markSprite?.stop()
play: -> @markSprite?.play()

View file

@ -210,7 +210,7 @@ module.exports = class SpriteBoss extends CocoClass
sprite.imageObject.play() for thangID, sprite of @sprites
@selectionMark?.play()
@targetMark?.play()
onCastSpells: ->
sprite.imageObject.stop() for thangID, sprite of @sprites
@selectionMark?.stop()

View file

@ -226,7 +226,7 @@ module.exports = Surface = class Surface extends CocoClass
@currentFrame = actualCurrentFrame
# TODO: are these needed, or perhaps do they duplicate things?
@spriteBoss.update()
@spriteBoss.update true
@onFrameChanged()
getCurrentFrame: ->
@ -304,7 +304,7 @@ module.exports = Surface = class Surface extends CocoClass
@casting = true
@wasPlayingWhenCastingBegan = @playing
Backbone.Mediator.publish 'level-set-playing', { playing: false }
createjs.Tween.removeTweens(@surfaceLayer)
createjs.Tween.get(@surfaceLayer).to({alpha:0.9}, 1000, createjs.Ease.getPowOut(4.0))
@ -312,7 +312,7 @@ module.exports = Surface = class Surface extends CocoClass
return unless event.world.name is @world.name
@casting = false
Backbone.Mediator.publish 'level-set-playing', { playing: @wasPlayingWhenCastingBegan }
fastForwardTo = null
if @playing
fastForwardTo = Math.min event.world.firstChangedFrame, @currentFrame

View file

@ -68,7 +68,7 @@ module.exports = class SpellPaletteView extends View
for prop in props
doc = _.find (allDocs[prop] ? []), (doc) ->
return true if doc.owner is owner
return (owner is 'this' or owner is 'more') and not doc.owner? or doc.owner is 'this'
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
console.log 'could not find doc for', prop, 'from', allDocs[prop], 'for', owner, 'of', propGroups unless doc
doc ?= prop
@entries.push @addEntry(doc, shortenize, tabbify, owner is 'snippets')