This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
es:orx:tutorials:frame [2009/09/07 13:45 (16 years ago)] – orgos | es:orx:tutorials:frame [2020/08/19 21:12 (5 years ago)] (current) – Old content sausage | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Tutorial de fotograma ====== | ||
- | |||
- | ===== Resumen ===== | ||
- | |||
- | See previous [[main# | ||
- | |||
- | All objects' | ||
- | These frames are assembled in a hierarchy graph, meaning that changing a parent frame properties will affect all its children. | ||
- | |||
- | In this tutorial, we have four objects that we link to a common parent ((an empty object, with no visual)) and a fifth one which has no parent.\\ | ||
- | The first two children are implicitely created using the object' | ||
- | The invisible parent object will follow the mouse cursor. Left shift and left control keys will respectively scale up and down the parent object, where as left and right clicks will apply a rotation to it.\\ | ||
- | All these transformations will affect its four children. | ||
- | |||
- | This provides us with an easy way to create complex or grouped objects and transform them (position, scale, rotation, speed, ...) very easily. | ||
- | |||
- | ===== Detalles ===== | ||
- | |||
- | As with the [[main# | ||
- | |||
- | <code c> | ||
- | |||
- | orxViewport_CreateFromConfig(" | ||
- | |||
- | We then create our parent object. | ||
- | |||
- | <code c> | ||
- | |||
- | As in the config file, for our '' | ||
- | |||
- | <code ini> | ||
- | ChildList = Object3 # Object4</ | ||
- | |||
- | Thus when we create our parent object, those two children (('' | ||
- | We could have done so for all the four children, but, for a learning purpose, we'll create the two remaining children in code | ||
- | and link them manually. | ||
- | |||
- | <code c> | ||
- | orxObject_CreateFromConfig(" | ||
- | pstObject = orxObject_CreateFromConfig(" | ||
- | orxObject_SetParent(pstObject, | ||
- | pstObject = orxObject_CreateFromConfig(" | ||
- | orxObject_SetParent(pstObject, | ||
- | </ | ||
- | |||
- | Here, '' | ||
- | |||
- | Please note that when we create and link manually objects in code, it's our responsability to delete them. On the contrary, '' | ||
- | |||
- | We then create a 100Hz clock and register our '' | ||
- | |||
- | <code c> | ||
- | |||
- | orxClock_Register(pstClock, | ||
- | |||
- | Let's now have a look to our '' | ||
- | First, we make sure we can find the position in our world space that corresponds to our mouse cursor in the screen space.\\ | ||
- | We then copy our '' | ||
- | |||
- | <code c> | ||
- | { | ||
- | orxVECTOR vParentPosition; | ||
- | orxObject_GetWorldPosition(pstParentObject, | ||
- | vPosition.fZ = vParentPosition.fZ; | ||
- | orxObject_SetPosition(pstParentObject, | ||
- | }</ | ||
- | |||
- | The only thing left to do is to apply scale and rotation according to our inputs.\\ | ||
- | In our case, we defined the following inputs in [[https:// | ||
- | |||
- | Let's see how we handle them. First, the rotations. | ||
- | |||
- | <code c> | ||
- | { | ||
- | orxObject_SetRotation(pstParentObject, | ||
- | } | ||
- | if(orxInput_IsActive(" | ||
- | { | ||
- | orxObject_SetRotation(pstParentObject, | ||
- | }</ | ||
- | |||
- | And now, the scales. | ||
- | |||
- | <code c> | ||
- | { | ||
- | orxObject_SetScale(pstParentObject, | ||
- | } | ||
- | if(orxInput_IsActive(" | ||
- | { | ||
- | orxObject_SetScale(pstParentObject, | ||
- | }</ | ||
- | |||
- | That's all! :-) Our '' | ||
- | |||
- | //NB:// | ||
- | |||
- | * //We could have used config values instead of constants for the rotation and scale values. This way, we could change them without having to recompile and even update them in real time by pressing// '' | ||
- | * //As we use the clock' | ||
- | |||
- | ===== Resources ===== | ||
- | |||
- | Source code: [[https:// | ||
- | |||
- | Config file: [[https:// | ||