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

OBY32

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


めがねもかけちゃえ!

オビーにメガネもつけられるようにしましたです。

■インスタンス変数追加

Obyクラス
インスタンス変数「glass」を追加です。
--------------------------------------------
Morph subclass: #Oby
	instanceVariableNames: 'face eye eyes nose lips ears hair hat memoryBank actionFlag addX addY glass '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'ObyMorph'
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )




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

Obyクラスglassメソッド
インスタンス変数glassを返すメソッド。
--------------------------------------------
glass
	^ glass
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )




ObyクラスaddRoundGlassメソッド
丸めがねをかけるメソッドっす。
EllipseMorphを2つとLineMorphでめがねにしてるです。
--------------------------------------------
addRoundGlass
	| leftGlass rightGlass |
	glass ifNotNil: [ glass delete].
	"メガネの生成"
	glass _ LineMorph new.
	glass borderColor: Color black.
	glass setVertices: {0@0. 9@-2. 18@0.}.

	leftGlass _ EllipseMorph new.
	leftGlass borderWidth: 2.
	leftGlass extent: 30@30.
	leftGlass color: (Color r: 0.5 g: 1.0 b: 1.0 alpha: 0.4).
	glass addMorph: leftGlass.
	leftGlass align: leftGlass center with: glass center + (-25@5).

	rightGlass _ EllipseMorph new.
	rightGlass borderWidth: 2.
	rightGlass extent: 30@30.
	rightGlass color: (Color r: 0.5 g: 1.0 b: 1.0 alpha: 0.4).
	glass addMorph: rightGlass.
	rightGlass align: rightGlass center with: glass center + (25@5).

	self addMorph: glass.
	glass align: glass center with: self center + (0 @ -3).
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )



ObyクラスaddRectangleGlassメソッド
四角のメガネをかけるメソッド。
RectangleMorphを2つとLineMorphでごんす。
--------------------------------------------
addRectangleGlass
	| leftGlass rightGlass |
	glass ifNotNil: [ glass delete].
	"メガネの生成"
	glass _ LineMorph new.
	glass borderColor: Color black.
	glass setVertices: {0@0. 9@-2. 18@0.}.

	leftGlass _ RectangleMorph new.
	leftGlass borderWidth: 2.
	leftGlass extent: 30@20.
	leftGlass color: (Color r: 0.5 g: 1.0 b: 1.0 alpha: 0.4).
	glass addMorph: leftGlass.
	leftGlass align: leftGlass center with: glass center + (-25@4).

	rightGlass _ RectangleMorph new.
	rightGlass borderWidth: 2.
	rightGlass extent: 30@20.
	rightGlass color: (Color r: 0.5 g: 1.0 b: 1.0 alpha: 0.4).
	glass addMorph: rightGlass.
	rightGlass align: rightGlass center with: glass center + (25@4).

	self addMorph: glass.
	glass align: glass center with: self center + (0 @ -3).
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )




■そろそろObyの半透明の枠をとっちゃうっす。

オビーの半透明の土台をずっとそのままにしてたけど、あんまり関係無さそうなんで透明にしちゃうです。
(なんで半透明にしたのか忘れちゃった。)
メソッド
alpha値を「0.5」から「0.0」にして透明にしますた。
--------------------------------------------
initialize
	super initialize.

	"土台の設定"
	self extent: 80@80.
	self color: (Color r: 1.0 g: 1.0 b: 1.0 alpha: 0.0).
	self borderWidth: 0.

	"顔の生成"
	face _ ObyFace new.
	self addMorph: face.
	face align: face center with: self center.

	"目の生成"
	eyes _ ObyEyes new.
	self addMorph: eyes.
	eyes align: eyes center with: self center + (0 @ 0).

	"口の生成"
	lips _ ObyLips new.
	self addMorph: lips.
	lips align: lips center with: self center + (0 @ 23).

	"鼻の生成"
	nose _ ObyNose new.
	self addMorph: nose.
	nose align: nose center with: self center + (0 @ 5).

	memoryBank _ Dictionary new.

	addX _ 2.
	addY _ 2.
	count _ 0.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )





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

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

        Uploaded Image: image.jpg


--------------------------------------------
boby addRectangleGlass.
--------------------------------------------
Alt + d ( Cmd + d )

        Uploaded Image: image1.jpg





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







■ MEMO ■

Links to this Page