mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Resolves #170, thang can be directly placed by dragging onto the map
This commit is contained in:
parent
02f8458dfe
commit
c05780de4c
2 changed files with 10 additions and 3 deletions
|
@ -103,6 +103,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@stage.removeAllChildren()
|
||||
@stage.removeEventListener 'stagemousemove', @onMouseMove
|
||||
@stage.removeEventListener 'stagemousedown', @onMouseDown
|
||||
@stage.removeEventListener 'stagemouseup', @onMouseUp
|
||||
@stage.removeAllEventListeners()
|
||||
@stage.enableDOMEvents false
|
||||
@stage.enableMouseOver 0
|
||||
|
@ -416,6 +417,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@stage.enableMouseOver(10)
|
||||
@stage.addEventListener 'stagemousemove', @onMouseMove
|
||||
@stage.addEventListener 'stagemousedown', @onMouseDown
|
||||
@stage.addEventListener 'stagemouseup', @onMouseUp
|
||||
@canvas.on 'mousewheel', @onMouseWheel
|
||||
@hookUpChooseControls() if @options.choosing
|
||||
createjs.Ticker.timingMode = createjs.Ticker.RAF_SYNCHED
|
||||
|
@ -539,6 +541,11 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
onBackground = not @stage.hitTest e.stageX, e.stageY
|
||||
Backbone.Mediator.publish 'surface:stage-mouse-down', onBackground: onBackground, x: e.stageX, y: e.stageY, originalEvent: e
|
||||
|
||||
onMouseUp: (e) =>
|
||||
return if @disabled
|
||||
onBackground = not @stage.hitTest e.stageX, e.stageY
|
||||
Backbone.Mediator.publish 'surface:stage-mouse-up', onBackground: onBackground, x: e.stageX, y: e.stageY, originalEvent: e
|
||||
|
||||
onMouseWheel: (e) =>
|
||||
# https://github.com/brandonaaron/jquery-mousewheel
|
||||
e.preventDefault()
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = class ThangsTabView extends View
|
|||
'sprite:dragged': 'onSpriteDragged'
|
||||
'sprite:mouse-up': 'onSpriteMouseUp'
|
||||
'sprite:double-clicked': 'onSpriteDoubleClicked'
|
||||
'surface:stage-mouse-down': 'onStageMouseDown'
|
||||
'surface:stage-mouse-up': 'onStageMouseUp'
|
||||
|
||||
events:
|
||||
'click #extant-thangs-filter button': 'onFilterExtantThangs'
|
||||
|
@ -108,7 +108,7 @@ module.exports = class ThangsTabView extends View
|
|||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
$('.tab-content').click @selectAddThang
|
||||
$('.tab-content').mousedown @selectAddThang
|
||||
$('#thangs-list').bind 'mousewheel', @preventBodyScrollingInThangList
|
||||
@$el.find('#extant-thangs-filter button:first').button('toggle')
|
||||
$(window).resize @onWindowResize
|
||||
|
@ -185,7 +185,7 @@ module.exports = class ThangsTabView extends View
|
|||
if e.originalEvent.nativeEvent.button == 2
|
||||
@onSpriteContextMenu e
|
||||
|
||||
onStageMouseDown: (e) ->
|
||||
onStageMouseUp: (e) ->
|
||||
if @addThangSprite
|
||||
# If we click on the background, we need to add @addThangSprite, but not if onSpriteMouseDown will fire.
|
||||
@backgroundAddClickTimeout = _.defer => @onExtantThangSelected {}
|
||||
|
|
Loading…
Reference in a new issue