Merge branch 'master' into production

This commit is contained in:
Michael Schmatz 2014-07-10 15:43:51 -07:00
commit 1bdc3e19f2
6 changed files with 36 additions and 24 deletions

View file

@ -45,8 +45,10 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
# Scale numbers # Scale numbers
baseScaleX: 1 # scale + flip (for current action) / resolutionFactor. baseScaleX: 1 # scale + flip (for current action) / resolutionFactor.
baseScaleY: 1 # These numbers rarely change, so keep them around. baseScaleY: 1 # These numbers rarely change, so keep them around.
scaleFactor: 1 # Current scale adjustment. This can change rapidly. scaleFactorX: 1 # Current scale adjustment. This can change rapidly.
targetScaleFactor: 1 # What the scaleFactor is going toward during a tween. scaleFactorY: 1
targetScaleFactorX: 1 # What the scaleFactor is going toward during a tween.
targetScaleFactorY: 1
# ACTION STATE # ACTION STATE
# Actions have relations. If you say 'move', 'move_side' may play because of a direction # Actions have relations. If you say 'move', 'move_side' may play because of a direction
@ -104,7 +106,10 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
finishSetup: -> finishSetup: ->
@updateBaseScale() @updateBaseScale()
@scaleFactor = @thang.scaleFactor if @thang?.scaleFactor @scaleFactorX = @thang.scaleFactorX if @thang?.scaleFactorX?
@scaleFactorX = @thang.scaleFactor if @thang?.scaleFactor?
@scaleFactorY = @thang.scaleFactorY if @thang?.scaleFactorY?
@scaleFactorY = @thang.scaleFactor if @thang?.scaleFactor?
@update true # Reflect initial scale and other state @update true # Reflect initial scale and other state
setUpRasterImage: -> setUpRasterImage: ->
@ -212,7 +217,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
# Gets the sprite to reflect what the current state of the thangs and surface are # Gets the sprite to reflect what the current state of the thangs and surface are
return if @stillLoading return if @stillLoading
@updatePosition() @updatePosition()
frameChanged = frameChanged or @targetScaleFactor isnt @scaleFactor frameChanged = frameChanged or @targetScaleFactorX isnt @scaleFactorX or @targetScaleFactorY isnt @scaleFactorY
if frameChanged if frameChanged
@handledDisplayEvents = {} @handledDisplayEvents = {}
@updateScale() # must happen before rotation @updateScale() # must happen before rotation
@ -351,14 +356,16 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
scaleX = 0.5 + 0.5 * (90 - angle) / 90 scaleX = 0.5 + 0.5 * (90 - angle) / 90
# console.error 'No thang for', @ unless @thang # console.error 'No thang for', @ unless @thang
# TODO: support using scaleFactorX/Y from the thang object @imageObject.scaleX = @baseScaleX * @scaleFactorX * scaleX
@imageObject.scaleX = @baseScaleX * @scaleFactor * scaleX @imageObject.scaleY = @baseScaleY * @scaleFactorY * scaleY
@imageObject.scaleY = @baseScaleY * @scaleFactor * scaleY
if @thang and (@thang.scaleFactor or 1) isnt @targetScaleFactor newScaleFactorX = @thang?.scaleFactorX ? @thang?.scaleFactor ? 1
newScaleFactorY = @thang?.scaleFactorY ? @thang?.scaleFactor ? 1
if @thang and (newScaleFactorX isnt @targetScaleFactorX or newScaleFactorY isnt @targetScaleFactorY)
@targetScaleFactorX = newScaleFactorX
@targetScaleFactorY = newScaleFactorY
createjs.Tween.removeTweens(@) createjs.Tween.removeTweens(@)
createjs.Tween.get(@).to({scaleFactor: @thang.scaleFactor or 1}, 2000, createjs.Ease.elasticOut) createjs.Tween.get(@).to({scaleFactorX: @targetScaleFactorX, scaleFactorY: @targetScaleFactorY}, 2000, createjs.Ease.elasticOut)
@targetScaleFactor = @thang.scaleFactor or 1
updateAlpha: -> updateAlpha: ->
@imageObject.alpha = if @hiding then 0 else 1 @imageObject.alpha = if @hiding then 0 else 1
@ -536,9 +543,8 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
pos.x *= scale pos.x *= scale
pos.y *= scale pos.y *= scale
if @thang and prop isnt 'registration' if @thang and prop isnt 'registration'
scaleFactor = @thang.scaleFactor ? 1 pos.x *= @thang.scaleFactorX ? @thang.scaleFactor ? 1
pos.x *= @thang.scaleFactorX ? scaleFactor pos.y *= @thang.scaleFactorY ? @thang.scaleFactor ? 1
pos.y *= @thang.scaleFactorY ? scaleFactor
# We might need to do this, but I don't have a good test case yet. TODO: figure out. # We might need to do this, but I don't have a good test case yet. TODO: figure out.
#if prop isnt @registration #if prop isnt @registration
# pos.x *= if @getActionProp 'flipX' then -1 else 1 # pos.x *= if @getActionProp 'flipX' then -1 else 1

View file

@ -257,6 +257,9 @@ module.exports = class Mark extends CocoClass
updateRotation: -> updateRotation: ->
if @name is 'debug' or (@name is 'shadow' and @sprite.thang?.shape in ['rectangle', 'box']) if @name is 'debug' or (@name is 'shadow' and @sprite.thang?.shape in ['rectangle', 'box'])
rot = @sprite.thang.rotation * 180 / Math.PI
unless @mark.rotation is rot
console.log @toString(), "updating rotation", @name, @sprite.thang?.shape, @sprite.thang?.rotation, "to", rot, "from", @mark.rotation
@mark.rotation = @sprite.thang.rotation * 180 / Math.PI @mark.rotation = @sprite.thang.rotation * 180 / Math.PI
updateScale: -> updateScale: ->

View file

@ -11,7 +11,7 @@ module.exports = class SpriteBoss extends CocoClass
subscriptions: subscriptions:
'bus:player-joined': 'onPlayerJoined' 'bus:player-joined': 'onPlayerJoined'
'bus:player-left': 'onPlayerLeft' 'bus:player-left': 'onPlayerLeft'
# 'level-set-debug': 'onSetDebug' 'level-set-debug': 'onSetDebug'
'level-highlight-sprites': 'onHighlightSprites' 'level-highlight-sprites': 'onHighlightSprites'
'surface:stage-mouse-down': 'onStageMouseDown' 'surface:stage-mouse-down': 'onStageMouseDown'
'level-select-sprite': 'onSelectSprite' 'level-select-sprite': 'onSelectSprite'

View file

@ -1,10 +1,10 @@
#employers-view #employers-view
.artisanal-claim .artisanal-claim
font-variant: small-caps //font-variant: small-caps
text-align: center text-align: center
font-size: 20px font-size: 20px
font-weight: bold font-weight: bold
font-family: Copperplate, "Copperplate Gothic Light", fantasy font-family: Arial, Helvetica, sans-serif
border-top: 1px solid #DBDBDB border-top: 1px solid #DBDBDB
border-bottom: 1px solid #DBDBDB border-bottom: 1px solid #DBDBDB
margin-bottom: 5px margin-bottom: 5px

View file

@ -143,6 +143,14 @@ module.exports = class PlayView extends View
] ]
arenas = [ arenas = [
#{
# name: 'Criss-Cross'
# difficulty: 4
# id: 'criss-cross'
# image: '/file/db/level/528aea2d7f37fc4e0700016b/its_a_trap_icon.png'
# description: 'Participate in a bidding war with opponents to reach the other side!'
# levelPath: 'ladder'
#}
{ {
name: 'Greed' name: 'Greed'
difficulty: 4 difficulty: 4

View file

@ -21,14 +21,8 @@ describe 'LevelComponent', ->
expect(err).toBeNull() expect(err).toBeNull()
done() done()
it 'can\'t be created by ordinary users.', (done) -> it 'can be created by ordinary users.', (done) ->
loginJoe -> loginJoe ->
request.post {uri: url, json: component}, (err, res, body) ->
expect(res.statusCode).toBe(403)
done()
it 'can be created by an admin.', (done) ->
loginAdmin ->
request.post {uri: url, json: component}, (err, res, body) -> request.post {uri: url, json: component}, (err, res, body) ->
expect(res.statusCode).toBe(200) expect(res.statusCode).toBe(200)
expect(body._id).toBeDefined() expect(body._id).toBeDefined()
@ -105,7 +99,8 @@ describe 'LevelComponent', ->
components[0].official = true components[0].official = true
loginJoe -> loginJoe ->
request.post {uri: url, json: components[0]}, (err, res, body) -> request.post {uri: url, json: components[0]}, (err, res, body) ->
expect(res.statusCode).toBe(403) expect(res.statusCode).toBe(200)
expect(body.official).toBe(false)
done() done()
it 'official property is editable by an admin.', (done) -> it 'official property is editable by an admin.', (done) ->