mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-01 00:15:00 -04:00
Use key.isPressed() to get movement direction
This commit is contained in:
parent
a092557973
commit
d7e031fd00
2 changed files with 17 additions and 17 deletions
app
|
@ -231,7 +231,8 @@ module.exports = class WizardSprite extends IndieSprite
|
||||||
super() if @displayObject.visible # not if we hid the wiz
|
super() if @displayObject.visible # not if we hid the wiz
|
||||||
|
|
||||||
moveWizard : (x, y) =>
|
moveWizard : (x, y) =>
|
||||||
|
interval = 250
|
||||||
position = {x: @targetPos.x+x, y: @targetPos.y+y}
|
position = {x: @targetPos.x+x, y: @targetPos.y+y}
|
||||||
@setTarget(position, 500, true)
|
@setTarget(position, interval, true)
|
||||||
@updatePosition()
|
@updatePosition()
|
||||||
Backbone.Mediator.publish 'camera-zoom-to', position, 500
|
Backbone.Mediator.publish 'camera-zoom-to', position, interval
|
|
@ -36,10 +36,10 @@ module.exports = class PlaybackView extends View
|
||||||
'⌘+p, p, ctrl+p': 'onTogglePlay'
|
'⌘+p, p, ctrl+p': 'onTogglePlay'
|
||||||
'⌘+[, ctrl+[': 'onScrubBack'
|
'⌘+[, ctrl+[': 'onScrubBack'
|
||||||
'⌘+], ctrl+]': 'onScrubForward'
|
'⌘+], ctrl+]': 'onScrubForward'
|
||||||
'w, up': 'onMoveUpKey'
|
'up': 'onMoveKey'
|
||||||
's, down': 'onMoveDownKey'
|
'down': 'onMoveKey'
|
||||||
'a, left': 'onMoveLeftKey'
|
'left': 'onMoveKey'
|
||||||
'd, right': 'onMoveRightKey'
|
'right': 'onMoveKey'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super(arguments...)
|
super(arguments...)
|
||||||
|
@ -220,14 +220,13 @@ module.exports = class PlaybackView extends View
|
||||||
@onWindowResize = null
|
@onWindowResize = null
|
||||||
super()
|
super()
|
||||||
|
|
||||||
onMoveUpKey: ->
|
onMoveKey: (e) ->
|
||||||
Backbone.Mediator.publish 'self-wizard:move', 0, 1
|
e?.preventDefault()
|
||||||
|
x = 0
|
||||||
onMoveDownKey: ->
|
y = 0
|
||||||
Backbone.Mediator.publish 'self-wizard:move', 0, -1
|
y = 1 if key.isPressed('up')
|
||||||
|
y = -1 if key.isPressed('down')
|
||||||
onMoveLeftKey: ->
|
x = 1 if key.isPressed('right')
|
||||||
Backbone.Mediator.publish 'self-wizard:move', -1, 0
|
x = -1 if key.isPressed('left')
|
||||||
|
console.log 'onMoveKey', x, y
|
||||||
onMoveRightKey: ->
|
Backbone.Mediator.publish 'self-wizard:move', x, y
|
||||||
Backbone.Mediator.publish 'self-wizard:move', 1, 0
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue