Clean up listener code

This commit is contained in:
oakes
2014-01-12 12:32:16 -05:00
parent 254698d325
commit d81cff935c
3 changed files with 14 additions and 15 deletions

View File

@@ -48,7 +48,7 @@
(reset-if-changed! entities old-entities)))))
listeners [(input-processor options execute-fn!)
(gesture-detector options execute-fn!)]
ui-listeners (ui/listeners options execute-fn!)
ui-listeners (ui/create-listeners options execute-fn!)
create-renderer-fn! #(swap! screen assoc :renderer (renderer %))
update-fn! #(swap! screen merge %)]
{:screen screen

View File

@@ -52,7 +52,6 @@
(doseq [{:keys [object]} entities]
(when (isa? (type object) Actor)
(.addActor ^Stage renderer object)
(.clearListeners ^Actor object)
(doseq [listener ui-listeners]
(.addListener ^Actor object listener))))
(remove-input! renderer)

View File

@@ -271,10 +271,10 @@
:pointer1 p1 :pointer2 p2))
(tap [e x y p b]
(execute-fn! on-ui-tap :event e :x x :y y :pointer p :button b))
;(touchDown [e x y p b]
; (execute-fn! on-ui-touch-down :event e :x x :y y :pointer p :button b))
;(touchUp [e x y p b]
; (execute-fn! on-ui-touch-up :event e :x x :y y :pointer p :button b))
(touchDown [e x y p b]
(execute-fn! on-ui-touch-down :event e :x x :y y :pointer p :button b))
(touchUp [e x y p b]
(execute-fn! on-ui-touch-up :event e :x x :y y :pointer p :button b))
(zoom [e id d]
(execute-fn! on-ui-zoom :event e :initial-distance id :distance d))))
@@ -297,7 +297,7 @@
(execute-fn! on-ui-exit :event e :x x :y y :pointer p :to-actor a))
(touchDown [e x y p b]
(execute-fn! on-ui-touch-down :event e :x x :y y :pointer p :button b)
true)
false)
(touchDragged [e x y p]
(execute-fn! on-ui-touch-dragged :event e :x x :y y :pointer p))
(touchUp [e x y p b]
@@ -308,13 +308,13 @@
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
execute-fn!]
(proxy [DragListener] []
;(touchDown [e x y p b]
; (execute-fn! on-ui-touch-down :event e :x x :y y :pointer p :button b)
; true)
;(touchDragged [e x y p]
; (execute-fn! on-ui-touch-dragged :event e :x x :y y :pointer p))
;(touchUp [e x y p b]
; (execute-fn! on-ui-touch-up :event e :x x :y y :pointer p :button b))
(touchDown [e x y p b]
(execute-fn! on-ui-touch-down :event e :x x :y y :pointer p :button b)
false)
(touchDragged [e x y p]
(execute-fn! on-ui-touch-dragged :event e :x x :y y :pointer p))
(touchUp [e x y p b]
(execute-fn! on-ui-touch-up :event e :x x :y y :pointer p :button b))
(drag [e x y p]
(execute-fn! on-ui-drag :event e :x x :y y :pointer p))
(dragStart [e x y p]
@@ -331,7 +331,7 @@
(scrollFocusChanged [e a f]
(execute-fn! on-ui-scroll-focus-changed :event e :actor a :focused? f))))
(defn listeners
(defn create-listeners
[options execute-fn!]
[(gesture-listener options execute-fn!)
(change-listener options execute-fn!)