我正在使用Quil與Clojure,並得到一個奇怪的錯誤。通過錯誤的參數數量,但我通過正確的金額
我得到的錯誤
Exception in :draw function: #error {
:cause Wrong number of args (1) passed to: core/move-circle/fn--14896
:via
這裏是唯一的代碼,動圈存在
(defn bounce-back [c state]
(or (<= (:x c) 0) (<= (:y c) 0) (>= (:x c) (inc (:size state))) (>= (:y c) (inc (:size state))))
)
(defn move-circle
"Moves a circle according to its speed and heading"
[c state]
(let [size (:size state) x (:x c) y (:y c) ux (atom 1) uy (atom 1) heading (atom (:heading c))]
(if (bounce-back c state) (swap! heading + q/PI) (swap! heading + 0))
(swap! ux #(mod 500 (* (q/cos @heading) (:speed c))))
(swap! uy #(mod 500 (* (q/sin @heading) (:speed c))))
(println "X: " x "Y: " y)
(println "UX: " @ux "Y: " @uy)
(update-in (update-in (update-in c [:y] #(+ y @uy)) [:x] #(+ x @ux)) [:heading] #(if (= @heading (:heading c)) (:heading c) @heading))
)
)
(defn update-circles
"Moves each circle and returns updated vector of circles."
[circles state]
(println "Update Circles")
(map (fn [c] (move-circle c state)) circles))
這裏是堆棧跟蹤
quil-workflow 0.1.0-SNAPSHOT[stdout]:
Update Circles
quil-workflow 0.1.0-SNAPSHOT[stdout]:
Exception in :draw function: #error {
:cause Wrong number of args (1) passed to: core/move-circle/fn--14896
:via
[{:type clojure.lang.ArityException
:message Wrong number of args (1) passed to: core/move-circle/fn--14896
:at [clojure.lang.AFn throwArity AFn.java 429]}]
:trace
[[clojure.lang.AFn throwArity AFn.java 429]
[clojure.lang.AFn invoke AFn.java 32]
[clojure.lang.Atom swap Atom.java 37]
[clojure.core$swap_BANG_ invokeStatic core.clj 2260]
[clojure.core$swap_BANG_ invoke core.clj 2253]
[circles.core$move_circle invokeStatic nil 55]
[circles.core$move_circle invoke nil 55]
[circles.core$update_circles$fn__14907 invoke nil 68]
[clojure.core$map$fn__4785 invoke core.clj 2646]
[clojure.lang.LazySeq sval LazySeq.java 40]
[clojure.lang.LazySeq seq LazySeq.java 49]
[clojure.lang.RT seq RT.java 521]
[clojure.core$seq__4357 invokeStatic core.clj 137]
[clojure.core$map$fn__4785 invoke core.clj 2637]
[clojure.lang.LazySeq sval LazySeq.java 40]
[clojure.lang.LazySeq seq LazySeq.java 49]
[clojure.lang.RT seq RT.java 521]
[clojure.core$seq__4357 invokeStatic core.clj 137]
[clojure.core$dorun invokeStatic core.clj 3024]
[clojure.core$dorun invoke core.clj 3024]
[circles.core$draw_state invokeStatic nil 92]
[circles.core$draw_state invoke nil 92]
[clojure.lang.Var invoke Var.java 379]
[quil.middlewares.fun_mode$wrap_draw_update$quil_draw__6769 invoke fun_mode.cljc 16]
[quil.middlewares.safe_fns$wrap_fn$fn__114 invoke safe_fns.clj 9]
[quil.middlewares.bind_output$bind_output$iter__148__152$fn__153$fn__164 invoke bind_output.clj 21]
[quil.applet$_draw invoke applet.clj 220]
[quil.Applet draw nil -1]
[processing.core.PApplet handleDraw PApplet.java 2402]
[quil.Applet handleDraw nil -1]
[processing.awt.PSurfaceAWT$12 callDraw PSurfaceAWT.java 1527]
[processing.core.PSurfaceNone$AnimationThread run PSurfaceNone.java 316]]}
stacktrace: clojure.lang.ArityException: Wrong number of args (1) passed to: core/move-circle/fn--14896
at clojure.lang.AFn.throwArity (AFn.java:429)
clojure.lang.AFn.invoke (AFn.java:32)
clojure.lang.Atom.swap (Atom.java:37)
clojure.core$swap_BANG_.invokeStatic (core.clj:2260)
clojure.core$swap_BANG_.invoke (core.clj:2253)
circles.core$move_circle.invokeStatic (:55)
circles.core$move_circle.invoke (:55)
circles.core$update_circles$fn__14907.invoke (:68)
clojure.core$map$fn__4785.invoke (core.clj:2646)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.RT.seq (RT.java:521)
clojure.core$seq__4357.invokeStatic (core.clj:137)
clojure.core$map$fn__4785.invoke (core.clj:2637)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.RT.seq (RT.java:521)
clojure.core$seq__4357.invokeStatic (core.clj:137)
clojure.core$dorun.invokeStatic (core.clj:3024)
clojure.core$dorun.invoke (core.clj:3024)
circles.core$draw_state.invokeStatic (:92)
circles.core$draw_state.invoke (:92)
clojure.lang.Var.invoke (Var.java:379)
quil.middlewares.fun_mode$wrap_draw_update$quil_draw__6769.invoke (fun_mode.cljc:16)
quil.middlewares.safe_fns$wrap_fn$fn__114.invoke (safe_fns.clj:9)
quil.middlewares.bind_output$bind_output$iter__148__152$fn__153$fn__164.invoke (bind_output.clj:21)
quil.applet$_draw.invoke (applet.clj:220)
quil.Applet.draw (:-1)
processing.core.PApplet.handleDraw (PApplet.java:2402)
quil.Applet.handleDraw (:-1)
processing.awt.PSurfaceAWT$12.callDraw (PSurfaceAWT.java:1527)
processing.core.PSurfaceNone$AnimationThread.run (PSurfaceNone.java:316)
你打電話給移動圈怎麼樣? – jmargolisvt
對不起,我想它沒有做一個填充複製粘貼。編輯我的主帖 –