OBY11
ってことで修正するです。パート1
各パーツの形を変えるってとこで躓いちゃったんだけど、解決方法を決定!!
(解決方法は決定するものなのかあ?)
第3案の「各パーツにも土台を設定してそこにかく形のモーフを生成しサブモーフにする」ってのにしました。
土台は「Morph」クラスでごんす。ってことで各顔のパーツのクラスを修正するです。
■ObyFaceクラスを修正
● クラス定義
EllipseMorphからMorphに変更。
インスタンス変数 face を定義
--------------------------------------------
Morph subclass: #ObyFace
instanceVariableNames: 'face '
classVariableNames: ''
poolDictionaries: ''
category: 'ObyMorph'
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● initializeメソッドを修正
顔の土台の色(透明ね)、大きさ設定
顔の形のEllipseMorphを生成しサブモーフに
--------------------------------------------
initialize
super initialize.
"顔の土台の設定"
self color: Color transparent.
self extent: 60@60.
"顔の生成と設定"
face _ EllipseMorph new.
face extent: 80@60.
face borderWidth: 1.
face color: (Color r: 0.4 g: 0.5 b: 0.3).
self addMorphFront: face.
face align: face center with: self center.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● faceメソッドを追加
インスタンス変数faceを返すメソッド
--------------------------------------------
face
^ face
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
■ObyEyeクラスを修正
● クラス定後
ObyEyeもEllipseMorphからMorphへ変更
インスタンス変数 eye を定義
--------------------------------------------
Morph subclass: #ObyEye
instanceVariableNames: 'eye iris '
classVariableNames: ''
poolDictionaries: ''
category: 'ObyMorph'
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● initializeメソッド
目の土台の色(透明ね)、大きさを設定
白目としてEllipseMorphを生成しサブモーフに
黒目としてEllipseMorphを作成し白目のサブモーフに
--------------------------------------------
initialize
super initialize.
"目の土台の設定"
self color: Color transparent.
self extent: 15@15.
"白目の設定"
eye _ EllipseMorph new.
eye color: (Color r: 1.0 g: 0.968 b: 0.935).
eye extent: 15 @ 15.
self addMorphFront: eye.
eye align: eye center with: self center.
"黒目の生成と設定"
iris _ EllipseMorph new.
iris extent: 6@6.
iris borderWidth: 0.
iris color: Color black.
eye addMorphFront: iris.
self lookAtFront
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● eyeメソッドを追加
インスタンス変数eyeを返すメソッド
--------------------------------------------
eye
^ eye
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
■ObyNoseクラスを修正
● クラス定義
同様にObyNoseクラスもEllipseMorphからMorphへ変更します。
インスタンス変数 nose 定義
--------------------------------------------
Morph subclass: #ObyNose
instanceVariableNames: 'nose gloss '
classVariableNames: ''
poolDictionaries: ''
category: 'ObyMorph'
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● initializeメソッド
鼻の土台の色(透明)、大きさ設定
鼻の形としてEllipseMorphを生成しサブモーフに
--------------------------------------------
initialize
super initialize.
"鼻の土台の設定"
self color: Color transparent.
self extent: 25@25.
"鼻の設定"
nose _ EllipseMorph new.
nose color: Color red.
nose extent: 20 @ 25.
self addMorph: nose.
nose align: nose center with: self center.
"ハイライト"
gloss _ EllipseMorph new.
gloss color: Color red.
gloss borderWidth: 0.
gloss extent: 10@10.
gloss position: nose position + 5.
nose addMorph: gloss.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● noseメソッドを追加
インスタンス変数noseを返すメソッド
--------------------------------------------
nose
^ nose
--------------------------------------------
アクセプト。
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
- OBY10 last edited on 22 March 2016 at 4:07:05 pm by localhost
- OBY12 last edited on 18 June 2007 at 5:25:21 am by localhost.localdomain