【发布时间】:2018-04-13 07:08:43
【问题描述】:
我正在做一个项目,我正在将 Pharo 中的 Lights Out 程序改编为扫雷程序,但我不知道如何向单元格添加文本,因此它会像颜色变化一样在点击时显示当它“打开”时。我到处寻找没有骰子的方法。 初始化方法:
initialize
super initialize.
self label: ''.
self borderWidth: 4.
mineState := false.
cellValue := 0.
bounds := 0@0 corner: 32@32.
offColor := Color paleYellow.
onColor := Color paleBlue darker.
self useSquareCorners.
self turnOff
新单元格代码:
newCellAt: i at: j
"Create a cell for position (i,j) and add it to my on-screen
representation at the appropriate screen position. Answer the new cell"
| c origin |
c := MFCell new.
"self labelString: 'hidden'."
origin := self innerBounds origin.
self addMorph: c.
c position: ((i - 1) * c width) @ ((j - 1) * c height) + origin.
c mouseAction: [self checkMineAt: i at: j].
^ c
【问题讨论】:
-
请检查我的回答。