我从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)发布于 2012-06-07 23:33:16
您的代码无法编译,因为您引用的数据构造函数RectangleWire不在作用域中。该错误指示如下:
main.hs:3:43: Not in scope: data constructor `RectangleWire'扫描documentation for Gloss看起来你要找的
rectangleWire :: Float -> Float -> PictureSource以原点为中心的线框矩形,具有给定的宽度和高度。从Graphics.Gloss.Data.Picture导出。
https://stackoverflow.com/questions/10934788
复制相似问题