mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-28 15:03:57 -04:00
Localized WizardSprite movement hey handling to WizardSprite file.
This commit is contained in:
parent
f2f0a993af
commit
86fd098159
2 changed files with 21 additions and 19 deletions
app
|
@ -21,7 +21,12 @@ module.exports = class WizardSprite extends IndieSprite
|
||||||
'surface:sprite-selected': 'onSpriteSelected'
|
'surface:sprite-selected': 'onSpriteSelected'
|
||||||
'echo-self-wizard-sprite': 'onEchoSelfWizardSprite'
|
'echo-self-wizard-sprite': 'onEchoSelfWizardSprite'
|
||||||
'echo-all-wizard-sprites': 'onEchoAllWizardSprites'
|
'echo-all-wizard-sprites': 'onEchoAllWizardSprites'
|
||||||
'self-wizard:move': 'moveWizard'
|
|
||||||
|
shortcuts:
|
||||||
|
'up': 'onMoveKey'
|
||||||
|
'down': 'onMoveKey'
|
||||||
|
'left': 'onMoveKey'
|
||||||
|
'right': 'onMoveKey'
|
||||||
|
|
||||||
constructor: (thangType, options) ->
|
constructor: (thangType, options) ->
|
||||||
if options?.isSelf
|
if options?.isSelf
|
||||||
|
@ -230,9 +235,21 @@ module.exports = class WizardSprite extends IndieSprite
|
||||||
updateMarks: ->
|
updateMarks: ->
|
||||||
super() if @displayObject.visible # not if we hid the wiz
|
super() if @displayObject.visible # not if we hid the wiz
|
||||||
|
|
||||||
moveWizard : (x, y) =>
|
|
||||||
|
onMoveKey: (e) ->
|
||||||
|
return unless @isSelf
|
||||||
|
e?.preventDefault()
|
||||||
|
yMovement = 0
|
||||||
|
xMovement = 0
|
||||||
|
yMovement += 2 if key.isPressed('up')
|
||||||
|
yMovement -= 2 if key.isPressed('down')
|
||||||
|
xMovement += 2 if key.isPressed('right')
|
||||||
|
xMovement -= 2 if key.isPressed('left')
|
||||||
|
@moveWizard xMovement, yMovement
|
||||||
|
|
||||||
|
moveWizard: (x, y) ->
|
||||||
interval = 500
|
interval = 500
|
||||||
position = {x: @targetPos.x+x, y: @targetPos.y+y}
|
position = {x: @targetPos.x + x, y: @targetPos.y + y}
|
||||||
@setTarget(position, interval, true)
|
@setTarget(position, interval, true)
|
||||||
@updatePosition()
|
@updatePosition()
|
||||||
Backbone.Mediator.publish 'camera-zoom-to', position, interval
|
Backbone.Mediator.publish 'camera-zoom-to', position, interval
|
||||||
|
|
|
@ -36,10 +36,6 @@ module.exports = class PlaybackView extends View
|
||||||
'⌘+p, p, ctrl+p': 'onTogglePlay'
|
'⌘+p, p, ctrl+p': 'onTogglePlay'
|
||||||
'⌘+[, ctrl+[': 'onScrubBack'
|
'⌘+[, ctrl+[': 'onScrubBack'
|
||||||
'⌘+], ctrl+]': 'onScrubForward'
|
'⌘+], ctrl+]': 'onScrubForward'
|
||||||
'up': 'onMoveKey'
|
|
||||||
'down': 'onMoveKey'
|
|
||||||
'left': 'onMoveKey'
|
|
||||||
'right': 'onMoveKey'
|
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super(arguments...)
|
super(arguments...)
|
||||||
|
@ -219,14 +215,3 @@ module.exports = class PlaybackView extends View
|
||||||
$(window).off('resize', @onWindowResize)
|
$(window).off('resize', @onWindowResize)
|
||||||
@onWindowResize = null
|
@onWindowResize = null
|
||||||
super()
|
super()
|
||||||
|
|
||||||
onMoveKey: (e) ->
|
|
||||||
e?.preventDefault()
|
|
||||||
yMovement = 0
|
|
||||||
xMovement = 0
|
|
||||||
yMovement += 2 if key.isPressed('up')
|
|
||||||
yMovement -= 2 if key.isPressed('down')
|
|
||||||
xMovement += 2 if key.isPressed('right')
|
|
||||||
xMovement -= 2 if key.isPressed('left')
|
|
||||||
console.log 'onMoveKey', xMovement, yMovement
|
|
||||||
Backbone.Mediator.publish 'self-wizard:move', xMovement, yMovement
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue