【发布时间】:2012-06-07 15:20:59
【问题描述】:
我从 C++ 切换到 Haskell 并使用 Gloss 制作游戏。 我在 main.hs 中编写了这个有效代码:
import Graphics.Gloss.Interface.Pure.Game
events (EventKey (Char 'a') Down _ _) _ = RectangleWire 10 10
events _ x = x
main = play (InWindow "GameEvent" (700, 100) (10, 10))
white
100
(Circle 10.0)
id
events
(\_ world -> world)
然后命令ghc main.hs回答:
[1 of 1] Compiling Main ( main.hs, main.o )
main.hs:3:43: Not in scope: data constructor `RectangleWire'
即使我安装了最新版本,我的 Gloss 库中似乎也缺少一些功能。例如,gloss-examples 包中的“Game Event”代码编译和运行完美(太漂亮了):
import Graphics.Gloss
-- | Display the last event received as text.
main
= play (InWindow "GameEvent" (700, 100) (10, 10))
white
100
""
(\str -> Translate (-340) 0 $ Scale 0.1 0.1 $ Text str)
(\event _ -> show event)
(\_ world -> world)
【问题讨论】:
-
好吧,如果它不编译显然是无效的。 AFAICS
Graphics.Gloss.Interface.Pure.Game不导出RectangleWire。 -
那是因为
RectangleWire不存在。Graphics.Gloss.Interface.Pure.Game导入Graphics.Gloss.Data.Picture并因此导入rectangleWire。我只是误读了函数的名称!有时,最好复制/粘贴...
标签: haskell compiler-errors gloss