View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

OBY31

PREV ------ ● TOP ● ------ NEXTUploaded Image: imager.jpg


お次は回転オビーね

オビーが一回転するアクションを追加するです。
後はなんかアクション思いついたら同様に追加していけばいいかにゃ・・・。

■メソッドを追加します。

Obyクラスrotatingメソッド
10度づつ回転してゆき一回転したら止まるって感じにしますた。
--------------------------------------------
rotating
	self heading: self heading + 10.
	self heading >= 360 ifTrue: [
		self actionFlag: 0.
		self heading: 0].
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )




■メソッドを修正。

Obyクラスstepメソッド
「actionFlag」が2の場合「rotating」メソッドを実行させまする。
--------------------------------------------
step
	super step.
	actionFlag = 1 ifTrue: [
		self bouncing].
	actionFlag = 2 ifTrue: [
		self rotating].
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )



★インスタンスを出してみる

--------------------------------------------
boby _ Oby new openInWorld.
boby actionFlag _ 2.
--------------------------------------------
Alt + d ( Cmd + d )

        Uploaded Image: image2.jpg





PREV ------ ● TOP ● ------ NEXT







■ MEMO ■

Links to this Page