can pan around only when nothing going on, can pan while zooming and stuff.
This commit is contained in:
@@ -190,6 +190,7 @@
|
||||
))))))
|
||||
|
||||
:on-touch-up (fn [screen entities options]
|
||||
(println "touched up!")
|
||||
(let [[x y] (utils/unproject screen options)]
|
||||
(when (seq (get-in entities [:state :choices]))
|
||||
(when-let [choice (first (filter #(utils/intersects? % [x y]) (get-in entities [:state :labels])))]
|
||||
@@ -286,7 +287,6 @@
|
||||
|
||||
:on-hover-start
|
||||
(fn [screen {:keys [all-icons] :as entities} {:keys [hover-text x y scene-viewport cursor ]}]
|
||||
(println cursor hover-text)
|
||||
(let [x (if utils/mobile? x (+ 8 x))
|
||||
[scene-x scene-y] (scene-world->talk-world scene-viewport [x y])
|
||||
depressed? (< 0.5 (- (or (:total-time screen) 0) (int (or (:total-time screen) 0))))
|
||||
|
||||
@@ -1169,6 +1169,8 @@ void main ()
|
||||
rooms
|
||||
(keys rooms))))
|
||||
|
||||
(defn remove-cam-tweens [entities]
|
||||
(update-in entities [:tweens] dissoc :cam-x :cam-y :cam-zoom))
|
||||
|
||||
|
||||
(defscreen scene
|
||||
@@ -1316,41 +1318,50 @@ void main ()
|
||||
|
||||
:on-pan
|
||||
(fn [screen entities {:keys [input-x input-y delta-x delta-y]}]
|
||||
(let [ideal-x (+ (get-in entities [:cam :x]) (- (/ delta-x 4)))
|
||||
ideal-y (+ (get-in entities [:cam :y]) (/ delta-y 4))]
|
||||
(-> entities
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cam :ideal-x] ideal-x)
|
||||
(assoc-in [:cam :ideal-y] ideal-y)
|
||||
(assoc-in [:cam :x] (utils/bound-to-camera ideal-x 320 (get-in entities [:cam :zoom])) )
|
||||
(assoc-in [:cam :y] (utils/bound-to-camera ideal-y 240 (get-in entities [:cam :zoom])) ))))
|
||||
(when (get-in entities [:state :active?])
|
||||
(let [ideal-x (+ (get-in entities [:cam :x]) (- (/ delta-x 4)))
|
||||
ideal-y (+ (get-in entities [:cam :y]) (/ delta-y 4))]
|
||||
(-> entities
|
||||
(remove-cam-tweens)
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cam :ideal-x] ideal-x)
|
||||
(assoc-in [:cam :ideal-y] ideal-y)
|
||||
(assoc-in [:cam :x] (utils/bound-to-camera ideal-x 320 (get-in entities [:cam :zoom])) )
|
||||
(assoc-in [:cam :y] (utils/bound-to-camera ideal-y 240 (get-in entities [:cam :zoom])) )))))
|
||||
|
||||
:pinch-stop
|
||||
(fn [screen entities options]
|
||||
(update-in entities [:cam] dissoc :start-zoom))
|
||||
(when (get-in entities [:state :active?])
|
||||
(-> entities
|
||||
(remove-cam-tweens)
|
||||
(update-in [:cam] dissoc :start-zoom))))
|
||||
|
||||
:on-pinch
|
||||
(fn [screen entities {:keys [initial-pointer-1 initial-pointer-2]}]
|
||||
(let [[pointer-1-x pointer-1-y] (utils/unproject screen nil [(.x initial-pointer-1) (.y initial-pointer-1)])
|
||||
[pointer-2-x pointer-2-y] (utils/unproject screen nil [(.x initial-pointer-2) (.y initial-pointer-2)])]
|
||||
(-> entities
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cam :ideal-x] (* 0.5 (+ pointer-1-x pointer-2-x)))
|
||||
(assoc-in [:cam :ideal-y] (* 0.5 (+ pointer-1-y pointer-2-y))))))
|
||||
(when (get-in entities [:state :active?])
|
||||
(let [[pointer-1-x pointer-1-y] (utils/unproject screen nil [(.x initial-pointer-1) (.y initial-pointer-1)])
|
||||
[pointer-2-x pointer-2-y] (utils/unproject screen nil [(.x initial-pointer-2) (.y initial-pointer-2)])]
|
||||
(-> entities
|
||||
(remove-cam-tweens)
|
||||
(assoc-in [:cursor :last-pos] [0 0])
|
||||
(assoc-in [:cam :ideal-x] (* 0.5 (+ pointer-1-x pointer-2-x)))
|
||||
(assoc-in [:cam :ideal-y] (* 0.5 (+ pointer-1-y pointer-2-y)))))))
|
||||
|
||||
:on-zoom
|
||||
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities {:keys [initial-distance distance]}]
|
||||
(let [start-zoom (get-in entities [:cam :start-zoom])
|
||||
zoom (get-in entities [:cam :zoom])
|
||||
entities (as-> entities entities
|
||||
(if (not start-zoom)
|
||||
(assoc-in entities [:cam :start-zoom] zoom)
|
||||
entities)
|
||||
(assoc-in entities [:cam :zoom] (max utils/max-zoom (min utils/min-zoom (* (or start-zoom zoom) (/ initial-distance distance)))))
|
||||
(assoc-in entities [:cam :x] (utils/bound-to-camera (get-in entities [:cam :ideal-x]) 320 (get-in entities [:cam :zoom])) )
|
||||
(assoc-in entities [:cam :y] (utils/bound-to-camera (get-in entities [:cam :ideal-y]) 240 (get-in entities [:cam :zoom])) ))]
|
||||
entities
|
||||
))
|
||||
(when (get-in entities [:state :active?])
|
||||
(let [start-zoom (get-in entities [:cam :start-zoom])
|
||||
zoom (get-in entities [:cam :zoom])
|
||||
entities (as-> entities entities
|
||||
(if (not start-zoom)
|
||||
(assoc-in entities [:cam :start-zoom] zoom)
|
||||
entities)
|
||||
(remove-cam-tweens entities)
|
||||
(assoc-in entities [:cam :zoom] (max utils/max-zoom (min utils/min-zoom (* (or start-zoom zoom) (/ initial-distance distance)))))
|
||||
(assoc-in entities [:cam :x] (utils/bound-to-camera (get-in entities [:cam :ideal-x]) 320 (get-in entities [:cam :zoom])) )
|
||||
(assoc-in entities [:cam :y] (utils/bound-to-camera (get-in entities [:cam :ideal-y]) 240 (get-in entities [:cam :zoom])) ))]
|
||||
entities
|
||||
)))
|
||||
|
||||
#_#_:on-scrolled
|
||||
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options]
|
||||
|
||||
Reference in New Issue
Block a user