you can drag inventory again on mobile.

This commit is contained in:
Bryce Covert
2016-12-12 08:50:37 -08:00
parent ca6cb94c54
commit cae0d35bed

View File

@@ -1322,34 +1322,37 @@ void main ()
:on-pan
(fn [screen entities {:keys [input-x input-y delta-x delta-y]}]
(when (and utils/mobile?
(get-in entities [:state :active?]))
(get-in entities [:state :active?])
(not (get-in entities [:cursor :came-from-inventory?])))
(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])) )))))
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]
(when (get-in entities [:state :active?])
(-> entities
(remove-cam-tweens)
(update-in [:cam] dissoc :start-zoom))))
(update-in [:cam] dissoc :start-zoom :pinching) )))
:on-pinch
(fn [screen entities {:keys [initial-pointer-1 initial-pointer-2]}]
(when (get-in entities [:state :active?])
(when (and (not (get-in entities [:cam :pinching]))
(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)))))))
(assoc-in [:cam :ideal-y] (* 0.5 (+ pointer-1-y pointer-2-y)))
(assoc-in [:cam :pinching] true)))))
:on-zoom
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities {:keys [initial-distance distance]}]
@@ -1367,7 +1370,7 @@ void main ()
entities
)))
:on-scrolled
#_#_:on-scrolled
(fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options]
(update-in entities [:cam :zoom] #(* % (+ 1 (/ (double (:amount options)) 10.0 )))))
@@ -1523,7 +1526,8 @@ void main ()
(assoc-in [:cursor :down-target] (or (:id interacting-entity ) (:id interaction) nil)))))))
:on-touch-up (fn [screen entities options]
(when-not utils/mobile?
(when (or (not utils/mobile?)
(get-in entities [:cursor :came-from-inventory?]))
(handle-touch-up screen entities options)))
:on-tap (fn [screen entities options]