OBY 6
FifthDay (これもうや〜めた)
オビーの目を2つにする
どうせ7日でできるわきゃないんでデイ・カウントはやんぴ。
って言うかめんどくさくなっちった。
てなわけでオビーを2つ目にしてやるわけですが全ページで作った「ObyEye」があるんで
そのインスタンスを2つだせばいいってことなんすよね。
両目を同時に扱えるようにする為と両目の間隔を調整しやすいように「目の土台」のクラスを作って
それに両目をサブモーフにしまする。
■クラスを作る
● ObyEyesクラス
「RectangleMorph」を親にして目の土台「ObyEyes」を定義します。
「ObyEyes」と「ObyEye」は区別してちょんまげ。
インスタンス変数は左眼、右目、両目の間隔を入れるためのものね。
--------------------------------------------
RectangleMorph subclass: #ObyEyes
instanceVariableNames: 'leftEye rightEye eyeBlank '
classVariableNames: ''
poolDictionaries: ''
category: 'ObyMorph'
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
■メソッドを追加します。
● initializeメソッド
両目の土台は
色は 透明
枠線は ナシ
大きさ 80@10
両目の間隔は 60
「ObyEye」を左眼として生成して
「ObyEyes」のサブモーフにします。
土台の「Oby」のセンターから「eyeBlank」の2分の1だけ左側へ
同様に
「ObyEye」を右眼として生成して
「ObyEyes」のサブモーフにします。
土台の「Oby」のセンターから「eyeBlank」の2分の1だけ右側へ
--------------------------------------------
initialize
super initialize.
"目の土台の設定"
self color: Color transparent.
self borderWidth: 0.
self extent: 80@10.
"両目の間隔"
eyeBlank _ 60.
"左眼生成"
self addMorph: (leftEye _ ObyEye new).
leftEye align: leftEye center with: self center - (eyeBlank // 2 @ 0).
"右目生成"
self addMorph: (rightEye _ ObyEye new).
rightEye align: rightEye center with: self center + (eyeBlank // 2 @ 0).
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● Obyクラスのinitializeメソッド
土台に両目をくっ付けます。
「ObyEyes」のインスタンスを生成し
土台の「Oby」のサブモーフにします。
「ObyEyes」のセンターと「Oby」のセンターを合わせまする。
--------------------------------------------
initialize
super initialize.
"土台の設定"
self extent: 80@80.
self color: (Color r: 1.0 g: 1.0 b: 1.0 alpha: 0.5).
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 @ 30).
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
★インスタンスを出してみる
--------------------------------------------
Oby new openInWorld
--------------------------------------------
Alt + d ( Cmd + d )
やっとこさ、顔らしくなってきたね!!
目のいろいろな表情のメソッドは後でじっくりこんとやりますることよ。
▲PREV ------ ● TOP ● ------ NEXT▼
■ MEMO ■
Links to this Page
- I BOBY last edited on 28 April 2004 at 8:57:55 pm by tk0005-202x210x196x109.ap-TK.usen.ad.jp
- OBY 5 last edited on 18 June 2007 at 5:16:14 am by localhost.localdomain
- OBY 7 last edited on 17 June 2007 at 7:30:51 am by localhost.localdomain