Working on different shadow shapes. Fixed bug with palette property ownership.

This commit is contained in:
Nick Winter 2014-02-24 17:53:35 -08:00
parent 4a4a702f1e
commit 3472b3da97
2 changed files with 21 additions and 12 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

@ -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')