mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Some fixes for CocoSprite alphas.
This commit is contained in:
parent
1f29a923cf
commit
81f8334f37
5 changed files with 26 additions and 8 deletions
|
@ -51,7 +51,12 @@ var console = {
|
|||
self.postMessage({type: 'console-log', args: args, id: self.workerID});
|
||||
}
|
||||
catch(error) {
|
||||
self.postMessage({type: 'console-log', args: ["Could not post log: " + args, error.toString(), error.stack, error.stackTrace], id: self.workerID});
|
||||
try {
|
||||
self.postMessage({type: 'console-log', args: ["Could not post log: " + args, error.toString(), error.stack, error.stackTrace], id: self.workerID});
|
||||
}
|
||||
catch(error2) {
|
||||
self.postMessage({type: 'console-log', args: ["Wow, we had a serious problem trying to console.log something."]});
|
||||
}
|
||||
}
|
||||
}
|
||||
}}; // so that we don't crash when debugging statements happen
|
||||
|
|
|
@ -364,9 +364,12 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
updateAlpha: ->
|
||||
@imageObject.alpha = if @hiding then 0 else 1
|
||||
return unless @thang?.alpha?
|
||||
return if @imageObject.alpha is @thang.alpha
|
||||
@imageObject.alpha = @thang.alpha
|
||||
if @options.showInvisible
|
||||
@imageObject.alpha = Math.max 0.5, @imageObject.alpha
|
||||
mark.updateAlpha @thang.alpha for name, mark of @marks
|
||||
@healthBar?.alpha = @thang.alpha
|
||||
|
||||
updateRotation: (imageObject) ->
|
||||
rotationType = @thangType.get('rotationType')
|
||||
|
|
|
@ -5,6 +5,7 @@ markThangTypes = {}
|
|||
|
||||
module.exports = class Mark extends CocoClass
|
||||
subscriptions: {}
|
||||
alpha: 1
|
||||
|
||||
constructor: (options) ->
|
||||
super()
|
||||
|
@ -216,11 +217,10 @@ module.exports = class Mark extends CocoClass
|
|||
true
|
||||
|
||||
updatePosition: (pos) ->
|
||||
if @name in ['shadow', 'debug']
|
||||
if @sprite?.thang and @name in ['shadow', 'debug', 'target', 'selection', 'repair']
|
||||
pos = @camera.worldToSurface x: @sprite.thang.pos.x, y: @sprite.thang.pos.y
|
||||
if @name is 'shadow'
|
||||
worldZ = @sprite.thang.pos.z - @sprite.thang.depth / 2 + @sprite.getBobOffset()
|
||||
@mark.alpha = 0.451 / Math.sqrt(worldZ / 2 + 1)
|
||||
@updateAlpha @alpha
|
||||
else
|
||||
pos ?= @sprite?.imageObject
|
||||
@mark.x = pos.x
|
||||
|
@ -231,6 +231,14 @@ module.exports = class Mark extends CocoClass
|
|||
@mark.y += offset.y
|
||||
@mark.y -= 3 if @statusEffect
|
||||
|
||||
updateAlpha: (@alpha) ->
|
||||
return if not @mark or @name is 'debug'
|
||||
if @name is 'shadow'
|
||||
worldZ = @sprite.thang.pos.z - @sprite.thang.depth / 2 + @sprite.getBobOffset()
|
||||
@mark.alpha = @alpha * 0.451 / Math.sqrt(worldZ / 2 + 1)
|
||||
else
|
||||
@mark.alpha = @alpha
|
||||
|
||||
updateRotation: ->
|
||||
if @name is 'debug' or (@name is 'shadow' and @sprite.thang?.shape in ["rectangle", "box"])
|
||||
@mark.rotation = @sprite.thang.rotation * 180 / Math.PI
|
||||
|
@ -242,12 +250,12 @@ module.exports = class Mark extends CocoClass
|
|||
oldMark.parent.addChild @mark
|
||||
oldMark.parent.swapChildren oldMark, @mark
|
||||
oldMark.parent.removeChild oldMark
|
||||
|
||||
|
||||
if @markSprite?
|
||||
@markSprite.scaleFactor = 1.2
|
||||
@markSprite.updateScale()
|
||||
return unless @name in ["selection", "target", "repair", "highlight"]
|
||||
|
||||
|
||||
# scale these marks to 10m (100px). Adjust based on sprite size.
|
||||
factor = 0.3 # default size: 3m width, most commonly for target when pointing to a location
|
||||
|
||||
|
@ -260,7 +268,7 @@ module.exports = class Mark extends CocoClass
|
|||
factor = Math.max(factor, 0.3) # lower bound
|
||||
@mark.scaleX *= factor
|
||||
@mark.scaleY *= factor
|
||||
|
||||
|
||||
if @name in ['selection', 'target', 'repair']
|
||||
@mark.scaleY *= @camera.y2x # code applies perspective
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = class LevelComponentEditView extends View
|
|||
super options
|
||||
@levelComponent = @supermodel.getModelByOriginalAndMajorVersion LevelComponent, options.original, options.majorVersion or 0
|
||||
console.log "Couldn't get levelComponent for", options, "from", @supermodel.models unless @levelComponent
|
||||
@onEditorChange = _.debounce @onEditorChange, 1500
|
||||
@onEditorChange = _.debounce @onEditorChange, 1000
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
|
|
|
@ -86,3 +86,5 @@ transpileLadderSessions = ->
|
|||
|
||||
serverSetup.connectToDatabase()
|
||||
transpileLadderSessions()
|
||||
# 2014-06-21: took about an hour to do 5480 sessions, ~93/min
|
||||
# eta: db.level.sessions.find({submitted: true}).count() / 93
|
||||
|
|
Loading…
Reference in a new issue