mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Some tweaks to the TrailMaster, consolidating some changes and altering the dot style.
This commit is contained in:
parent
c40a7c1bb8
commit
e93de815c2
1 changed files with 18 additions and 14 deletions
|
@ -2,13 +2,15 @@ PAST_PATH_ALPHA = 0.75
|
|||
PAST_PATH_WIDTH = 5
|
||||
FUTURE_PATH_ALPHA = 0.4
|
||||
FUTURE_PATH_WIDTH = 2
|
||||
TARGET_ALPHA = 1
|
||||
TARGET_WIDTH = 10
|
||||
FUTURE_PATH_INTERVAL_DIVISOR = 4
|
||||
PAST_PATH_INTERVAL_DIVISOR = 2
|
||||
|
||||
Camera = require './Camera'
|
||||
CocoClass = require 'lib/CocoClass'
|
||||
|
||||
module.exports = class TrailMaster extends CocoClass
|
||||
paths: null # dictionary of thang ids to containers for their paths
|
||||
pathDisplayObject: null
|
||||
world: null
|
||||
|
||||
constructor: (@camera, @layerAdapter) ->
|
||||
|
@ -22,13 +24,13 @@ module.exports = class TrailMaster extends CocoClass
|
|||
@generatingPaths = true
|
||||
@cleanUp()
|
||||
@createGraphics()
|
||||
@pathDisplayObject = new createjs.SpriteContainer(@layerAdapter.spriteSheet)
|
||||
@pathDisplayObject.mouseEnabled = @pathDisplayObject.mouseChildren = false
|
||||
@pathDisplayObject.addChild @createFuturePath()
|
||||
# @pathDisplayObject.addChild @createPastPath() # Just made the animated path the full path... do we want to have past and future look different again?
|
||||
@pathDisplayObject.addChild @createTargets()
|
||||
pathDisplayObject = new createjs.SpriteContainer(@layerAdapter.spriteSheet)
|
||||
pathDisplayObject.mouseEnabled = pathDisplayObject.mouseChildren = false
|
||||
pathDisplayObject.addChild @createFuturePath()
|
||||
# pathDisplayObject.addChild @createPastPath() # Just made the animated path the full path... do we want to have past and future look different again?
|
||||
pathDisplayObject.addChild @createTargets()
|
||||
@generatingPaths = false
|
||||
return @pathDisplayObject
|
||||
return pathDisplayObject
|
||||
|
||||
cleanUp: ->
|
||||
createjs.Tween.removeTweens(sprite) for sprite in @tweenedSprites
|
||||
|
@ -36,9 +38,8 @@ module.exports = class TrailMaster extends CocoClass
|
|||
@tweens = []
|
||||
|
||||
createGraphics: ->
|
||||
color = @colorForThang(@thang.team, PAST_PATH_ALPHA)
|
||||
@targetDotKey = @cachePathDot(10, color)
|
||||
@pastDotKey = @cachePathDot(PAST_PATH_WIDTH, color)
|
||||
@targetDotKey = @cachePathDot(TARGET_WIDTH, @colorForThang(@thang.team, TARGET_ALPHA))
|
||||
@pastDotKey = @cachePathDot(PAST_PATH_WIDTH, @colorForThang(@thang.team, PAST_PATH_ALPHA))
|
||||
@futureDotKey = @cachePathDot(FUTURE_PATH_WIDTH, @colorForThang(@thang.team, FUTURE_PATH_ALPHA))
|
||||
|
||||
cachePathDot: (width, color) ->
|
||||
|
@ -47,7 +48,7 @@ module.exports = class TrailMaster extends CocoClass
|
|||
unless key in @layerAdapter.spriteSheet.getAnimations()
|
||||
circle = new createjs.Shape()
|
||||
radius = width/2
|
||||
circle.graphics.setStrokeStyle(1).beginFill(color).beginStroke('#000000').drawCircle(0, 0, radius)
|
||||
circle.graphics.setStrokeStyle(width/5).beginFill(color).beginStroke('#000000').drawCircle(0, 0, radius)
|
||||
@layerAdapter.addCustomGraphic(key, circle, [-radius*1.5, -radius*1.5, radius*3, radius*3])
|
||||
return key
|
||||
|
||||
|
@ -60,12 +61,13 @@ module.exports = class TrailMaster extends CocoClass
|
|||
|
||||
createPastPath: ->
|
||||
return unless points = @world.pointsForThang @thang.id, @camera
|
||||
params = { interval: 8, frameKey: @pastDotKey }
|
||||
interval = Math.max(1, parseInt(@world.frameRate / PAST_PATH_INTERVAL_DIVISOR))
|
||||
params = { interval: interval, frameKey: @pastDotKey }
|
||||
return @createPath(points, params)
|
||||
|
||||
createFuturePath: ->
|
||||
return unless points = @world.pointsForThang @thang.id, @camera
|
||||
interval = Math.max(1, parseInt(@world.frameRate / 4))
|
||||
interval = Math.max(1, parseInt(@world.frameRate / FUTURE_PATH_INTERVAL_DIVISOR))
|
||||
params = { interval: interval, animate: true, frameKey: @futureDotKey }
|
||||
return @createPath(points, params)
|
||||
|
||||
|
@ -77,6 +79,7 @@ module.exports = class TrailMaster extends CocoClass
|
|||
sup = @camera.worldToSurface x: x, y: y
|
||||
sprite = new createjs.Sprite(@layerAdapter.spriteSheet)
|
||||
sprite.scaleX = sprite.scaleY = 1 / @layerAdapter.resolutionFactor
|
||||
sprite.scaleY *= @camera.y2x
|
||||
sprite.gotoAndStop(@targetDotKey)
|
||||
sprite.x = sup.x
|
||||
sprite.y = sup.y
|
||||
|
@ -93,6 +96,7 @@ module.exports = class TrailMaster extends CocoClass
|
|||
y = points[i + 1]
|
||||
sprite = new createjs.Sprite(@layerAdapter.spriteSheet)
|
||||
sprite.scaleX = sprite.scaleY = 1 / @layerAdapter.resolutionFactor
|
||||
sprite.scaleY *= @camera.y2x
|
||||
sprite.gotoAndStop(key)
|
||||
sprite.x = x
|
||||
sprite.y = y
|
||||
|
|
Loading…
Reference in a new issue