OBY 7
オビーに鼻をつける
オビーにお鼻をつけてやりましょう!そうしましょ!
■クラスを作る
● ObyNoseクラス
「EllipseMorph」を親にして定義しまする。
インスタンス変数はハイライトを入れるためのものね。
--------------------------------------------
EllipseMorph subclass: #ObyNose
instanceVariableNames: 'gloss '
classVariableNames: ''
poolDictionaries: ''
category: 'ObyMorph'
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
■メソッドを追加します。
● initializeメソッド
鼻の色は 赤
大きさは 20@25
ハイライトも用意しておきます。(鼻のテカリね)
「EllipseMorph」のインスタンスを新たに生成します。
色は 赤(取り敢えずは同色にしたです。白にするとテカリます)
枠線は ナシ
大きさは 10@10
位置は鼻の左上にくるようにするです。
--------------------------------------------
initialize
super initialize.
"鼻の設定"
self color: Color red.
self extent: 20 @ 25.
"ハイライト"
gloss _ EllipseMorph new.
gloss color: Color red.
gloss borderWidth: 0.
gloss extent: 10@10.
gloss position: 5@5.
self addMorph: gloss.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● Obyクラスのinitializeメソッドを修正する
鼻を土台にくっ付けます。
「ObyNose」のインスタンスを生成し
土台の「Oby」のサブモーフにします。
横の位置は「Oby」のセンターに、縦の位置は「Oby」のセンターより5下です。
--------------------------------------------
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).
"鼻の生成"
nose _ ObyNose new.
self addMorph: nose.
nose align: nose center with: self center + (0 @ 5).
"口の生成"
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 )
赤鼻のオビーってかんじね!!変な顔。
あと追加する基本のパーツは耳とかヘアー、鬚とかあるです。
耳は「ObyEyes」みたく作ればよさそうだし、ヘアーとか鬚は「PolygonMorph」で形を作ればいいんで
「ObyLip」みたくやれば大丈夫そうだね。だからそれらに関しては省略するかも。
ただ、PolygonMorphで形を作るのってどうやってポイントの位置を決まるのかって〜のは
やるかもでする。ま、気分次第なんですけどね。
▲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 6 last edited on 23 March 2011 at 4:12:20 am by 65.49.33.65
- OBY 8 last edited on 18 June 2007 at 5:28:17 am by localhost.localdomain