User Tools

Site Tools


en:orx:reference:object:snippets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:orx:reference:object:snippets [2013/10/24 08:39 (12 years ago)] – structure code snippet sausageen:orx:reference:object:snippets [2018/01/21 02:53 (8 years ago)] (current) – Content moved. Deleted. sausage
Line 1: Line 1:
-====== Object: Code Snippets ====== 
- 
- 
-===== OrxFrame ===== 
- 
- 
-===== OrxFX ===== 
- 
- 
-===== OrxFXPointer ===== 
- 
- 
-===== OrxObject ===== 
- 
-==== OrxObject_SetPosition ==== 
- 
-  orxVECTOR tilePos; 
-  orxVector_Set(&tilePos, orx2F(80.0f) * x, orx2F(160.0f), orxFLOAT_0); 
-  orxObject_SetPosition(tile, &tilePos); 
- 
-  orxVECTOR pos; 
-  orxObject_GetPosition(player, &pos); 
-  pos.fX = -pos.fX; 
-  orxObject_SetPosition(player, &pos); 
- 
-==== orxObject_SetRotation ==== 
- 
-Rotation is set in radians. Zero rad vector is equivalent to (1, 0) vector in screen coordinates. In other words it is a horizontal line pointing from left to right. 
- 
-Positive rotation is set in clockwise direction. If vector origin was in the center of the screen, then 1 rad would point to the bottom right corner of the screen. 
-==== orxObject_SetAngularVelocity ==== 
- 
-Set angular velocity changes object rotation value over time. Setting positive value make object rotate clockwise. 
- 
-TBD: What's the unit of measure? 
- 
-By default object starts with zero rotation angle which points horizontally from left to right. As object rotates a full circle its rotation angle value will not reset to zero. Instead it will continue to grow in positive or negative direction according to angular velocity value. 
- 
-Thus after one full circle the object rotation value will satisfy the condition: 
-<code> 
-orxMath_Abs(orxObject_GetRotation(obj)) >= orxMATH_KF_2_PI 
-</code> 
-==== orxObject_GetWorldRotation and orxObject_GetRotation ==== 
- 
-Returns current object rotation value in rad. The value returned can be any floating value. 
- 
-See orxObject_SetRotation for coordinate system reference.   
-See orxObject_SetAngularVelocity for discussion of continuous rotation. 
-==== orxObject_CreateNeighborList and orxObject_DeleteNeighborList ==== 
- 
-Use it to obtain objects within the specified bounding box. 
- 
-<code c> 
-    orxOBJECt *obj; // comes from mouse click event or in some other way 
-    orxVECTOR pos, size; 
-    orxFLOAT range = orx2F(250.f); 
-    orxOBOX box; 
-     
-    orxObject_GetWorldPosition(obj, &pos); 
-    orxVector_Set(&size, range, range, orxFLOAT_0); 
-    orxOBox_2DSet(&box, &pos, &orxVECTOR_0, &size, orxFLOAT_0); 
- 
-    orxBANK *neighbors = orxObject_CreateNeighborList(box); 
-    void* cell = orxNULL; 
-    while ((cell = orxBank_GetNext(neighbors, cell))) { 
-        orxOBJECT **n = cell; 
-        orxLOG("object name: %s.", orxObject_GetName(*n)); 
-    } 
-    orxObject_DeleteNeighborList(neighbors); 
-</code> 
-==== object traversing ==== 
- 
-[[en:orx:tutorials:community:sergeig:objecttreetraversing|Object Traversing]] has its own page due to somewhat large discussion on the topic. 
- 
-===== OrxSpawner ===== 
- 
- orxSTRUCTURE *structure = orxStructure_GetFirst(orxSTRUCTURE_ID_SPAWNER ); 
- while (structure != orxNULL){ 
- orxSPAWNER *spawn = orxSPAWNER(structure); 
- if (orxString_Compare(orxSpawner_GetName(spawn), spawnerName) == 0 ){ 
- return spawn; 
- } else { 
- structure = orxStructure_GetNext(structure ); 
- } 
- } 
-===== OrxStructure ===== 
- 
- orxSTRUCTURE *structure = orxStructure_GetFirst(orxSTRUCTURE_ID_OBJECT); 
- while (structure != orxNULL){ 
- orxOBJECT *object = orxOBJECT(structure); 
- const orxSTRING objectName = orxObject_GetName(object); 
- orxSTRUCTURE *nextStructure = orxStructure_GetNext(structure);  
- if (orxString_Compare(objectName , "SomeObjectName") == 0){ 
- orxObject_SetLifeTime(orxOBJECT(structure), orx2F(0.0)); 
- } 
- structure = nextStructure; 
- } 
- 
- 
-===== OrxTimeLine ===== 
- 
  
en/orx/reference/object/snippets.1382629185.txt.gz · Last modified: 2017/05/30 00:50 (8 years ago) (external edit)