User Tools

Site Tools


en:tutorials:useparentspace_for_spawners

Differences

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

Link to this comparison view

en:tutorials:useparentspace_for_spawners [2019/06/13 22:08 (10 months ago)]
sausage Review changes and further info
en:tutorials:useparentspace_for_spawners [2019/06/14 01:48 (10 months ago)]
Line 1: Line 1:
-====== UseParentSpace for Spawners using Relative Position and Scale ====== 
- 
-This is a follow-on from [[en:​tutorials:​useparentspace|UseParentSpace for Relative Object Positioning and Scaling]]. 
- 
-In the same way that child Objects can use the ''​UseParentSpace''​ property to operate within a Parent'​s relative position and scale... spawners can benefit from the same functionality. 
- 
-{{page>::​init_new_project&​nofooter&​noeditbutton}} 
- 
- 
-===== Objects and Spawners ===== 
- 
-In general when specifying what object to spawn, the object is given co-ordinates in world space like: 
- 
-    Position = (35, 100, 0.0) 
-  
-With relative positioning,​ the object that is spawned will be positioned relative to the Parent Object'​s Size (The Parent Object is one that has a spawner attached). 
- 
-That can be confusing. Let's view it as a tree: 
- 
-  * Main Object 
-    * Spawner connected 
-      * Object to Spawn 
- 
-It is the Object to Spawn, that will use the ''​UseParentSpace''​ property. 
- 
-But before we get there, let's set up a spawner in the usual screen coordinate way. 
- 
- 
-===== Making it rain ===== 
- 
-Start by making a rain cloud that spawns raindrops. Here's a cloud for you to use: 
- 
-<WRAP center round box 90%> 
-{{ :​tutorials:​cloud.png?​nolink |}}  
-</​WRAP>​ 
- 
- 
-  
- 
-Define a ''​Cloud''​ object in config: 
- 
-<code ini> 
-[Cloud] 
-Spawner ​ = RainSpawner 
-Pivot    = center 
-Graphic ​ = @ 
-Texture ​ = cloud.png 
-Position = (0.0, -200.0, -0.1) 
-</​code>​ 
- 
-Then change the ''​Object''​ to ''​Cloud''​ in the create line in the code: 
- 
-<code c> 
-orxObject_CreateFromConfig("​Cloud"​);​ 
-</​code>​ 
- 
-This will create a cloud object a little up from the centre of the screen. We haven'​t provided a spawner yet so it doesn'​t do anything. So define both the spawner and object to spawn with: 
- 
-<code ini> 
-[RainSpawner] 
-Object ​          = RainDrop 
-TotalObject ​     = 0 
-ActiveObject ​    = 1000 
-WaveSize ​        = 5 
-WaveDelay ​       = 0.016 ~ 0.03 
-ObjectSpeed ​     = (0, 800) 
-Rotation ​        = 22.5 
-UseRelativeSpeed = true 
- 
-[RainDrop] 
-Graphic ​       = @ 
-Texture ​       = pixel 
-Size           = (1,20) ~ (1,40) 
-Alpha          = 0.3 ~ 0.8 
-Color          = (255,​255,​255) 
-Pivot          = top 
-AutoScroll ​    = both 
-DepthScale ​    = true 
-LifeTime ​      = 1.0 
-Smoothing ​     = true 
-Position ​      = (-50.0, 00.0, 0.0) ~ (90.0, 00.0, 0.5) 
-</​code>​ 
- 
-In the spawner config above, we're making ''​RainSpawner''​ spawn ''​RainDrop''​ objects, lots of them, in a fast down direction, but rotating the spawner by 22 degrees (plus using relative speed) to get a nice down-left direction for the rain. 
- 
-For the ''​RainDrop''​ objects themselves, we vary their alpha transparency,​ stretched size and their starting position on screen between X = -50.0 to 90.0. 
- 
-There is no image for the raindrops, we're just using a stretched pixel. That will do nicely. ​ 
- 
-{{ :​tutorials:​raining.png?​nolink |}} 
- 
- 
-===== Relative Spawner Positioning ===== 
- 
-The last step is to convert the positioning to be relative to the Cloud'​s size. This means changing the ''​Position''​ property of the ''​RainDrop''​ and setting ''​UseParentSpace''​ to position: 
- 
-<code ini> 
-[RainDrop] 
-Graphic ​       = @ 
-Texture ​       = pixel 
-Scale          = (1,20) ~ (1,40) 
-Alpha          = 0.3 ~ 0.8 
-Color          = (255,​255,​255) 
-Pivot          = top 
-AutoScroll ​    = both 
-DepthScale ​    = true 
-LifeTime ​      = 1.0 
-Smoothing ​     = true 
-Rotation ​      = 22.5 
-Position ​      = (-0.3, 0.0, 0.0) ~ (0.45, 0.0, 0.5) 
-UseParentSpace = position 
-</​code> ​ 
- 
-Because the pivot of the ''​Cloud''​ is centred, the coordinate range is (-0.5, -0.5) to (0.5, 0.5). I've adjusted the X positions to between -0.3 and 0.45 to bring the positions in a little to work nicer with the cloud itself. 
- 
-The result should be the same: 
- 
-{{ :​tutorials:​raining.png?​nolink |}} 
- 
- 
-==== Further information ==== 
-  - Ordered List Item[[en:​tutorials:​useparentspace|UseParentSpace for Relative Object Positioning and Scaling]] 
-  - [[en:​orx:​config:​settings_structure:​orxobject|Object Configuration]] 
  
en/tutorials/useparentspace_for_spawners.txt ยท Last modified: 2019/06/14 01:48 (10 months ago) (external edit)