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/08 11:42 (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 marco ====== | ||
- | |||
- | ===== Resumen ===== | ||
- | |||
- | Para mas información vea [[main# | ||
- | |||
- | Las propiedades de los objetos como: posiciones, escalas y rotacion son almacenadas en las estructura '' | ||
- | Estos marcos estan juntos en la jerarquia de gráficos, lo que significa que las propiedades del marco padre afectaran las propiedades de sus hijos. | ||
- | |||
- | En este tutorial, tenemos 4 objetos que serán vinculados a un padre en comun ((un objeto vacio, sin contenido visual)) y un quinto sin padre.\\ | ||
- | Los dos primeros hijos son creados usando las propiedades de objetos de la configuración '' | ||
- | El objeto padre invisible seguira el puntero del ratón. Las teclas "SHIFT IZQUIERDA" | ||
- | Todas estas transformaciones afectaran a los 4 hijos. | ||
- | |||
- | Esto nos mostrará una forma fácil de crear grupos de objetos complejos y transformar sus propiedades (posicion, escala, rotación, vélocidad...) facilmente. | ||
- | |||
- | ===== 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' | ||
- | |||
- | ===== Recursos ===== | ||
- | |||
- | Código fuente: [[https:// | ||
- | |||
- | Fichero de configuración: | ||