TGroup subclass: #Name-of-the-piece instanceVariableNames: 'inControl tframe ' classVariableNames: '' poolDictionaries: '' category: 'MyCroquet'
handlesKeyboard: pointer ^ true.
The 2nd method:
handlesPointerDown: pointer ^ true.
The 3th method:
isComponent ^ true.
initialize
super initialize.
tframe := (TLoad3DSMax new initializeWithFileName:
(FileDirectory pathFrom:
{FileDirectory default pathName. 'Content'. 'name-of-the-piece'. 'name-of-the-file-for-the-piece.ase'})
scale: 0.1 shadeAngle: 90.1 textureMode: GLReplace) frame.
tframe collapse.
tframe boundsDepth: 3.
tframe initBounds.
self addChild: tframe.
tframe objectOwner: self.
inControl := false.
keyDown: pointer | c | c := pointer event2D keyCharacter. "To move X+" c = $w ifTrue:[ tframe translation: tframe translation+( tframe localTransform column1*0.5). inControl := true. ]. "To move X-" c = $s ifTrue:[ tframe translation: tframe translation-( tframe localTransform column1*0.5). inControl := true. ]. "To turn left" c = $a ifTrue:[ tframe addRotationAroundY:-1. inControl := true. ]. "To turn right" c = $d ifTrue:[ tframe addRotationAroundY: 1. inControl :=true. ]. "To go up:Y+" c = $z ifTrue:[ tframe translation: tframe translation+( tframe localTransform column2*0.5). inControl := true. ]. "To go down (oops!):Y-" c = $x ifTrue:[ tframe translation: tframe translation-( tframe localTransform column2*0.5). inControl := true. ]. "To move Z+" c = $c ifTrue:[ tframe translation: tframe translation+( tframe localTransform column3*0.5). inControl:= true. ]. "To move Z-" c = $v ifTrue:[ "Z-" tframe translation: tframe translation-( tframe localTransform column3*0.5). inControl := true. ]. "To create a clone". (c = $r) ifTrue:[ tframe:=Name-of-the-piece new. self addChild:tframe. tframe translationX: 50 y: 0 z: -50. inControl := true. ].