*Tip for spawning Static actors
sparkania
Member, PRO Posts: 300
Just wanted to share a practice of mine just in case it might help someone. I'm pretty sure many others do something similar but just in case..
I am defining a 'Static Actor' as any actor which will be spawned to the same location on the viewable screen during gameplay. Score, Buttons, Alerts, Text Info.. etc..
The first thing I make in nearly all of my projects is an actor called "Center Dummy". (Dummy is a common term in 3D for a controller object which exists only to assist, but not as a Visual part of the project)
First create 2 Game level reals
CenterX
CenterY
Create an actor of any small size (12x12) drag it to your stage and place it anywhere. Then constrain to the center of the scene.
Uncheck Moveable
Uncheck Visible
Check Fixed Rotation
Assign these 4 blocks to Dummy Center Actor
Constrain Attribute
self.position.X to scene.camera.origin.X + (half of the Width of the Scene)
Constrain Attribute
self.position.Y to scene.camera.origin.Y + (half of the Height of the Scene)
Constrain Attribute
game.CenterX to self.position.X
Constrain Attribute
game.CenterY to self.position.Y
Now you have usable Center coordinates which can be used by all spawned or current actors.
This does not have to be in the center of the screen.. Lets say you have a Control area on the bottom of the screen.. and an information bar at the top.
You could create 2 such Dummy actors (dont forget to add another pair of Game reals) which represent the center of those two areas. Then your Spawns only need to be set up adding or subtracting just the X or Y coordinate from the Dummy.
This process will just save you a little Math when trying to have items pop up during your game.
Hope this Helps..
I am defining a 'Static Actor' as any actor which will be spawned to the same location on the viewable screen during gameplay. Score, Buttons, Alerts, Text Info.. etc..
The first thing I make in nearly all of my projects is an actor called "Center Dummy". (Dummy is a common term in 3D for a controller object which exists only to assist, but not as a Visual part of the project)
First create 2 Game level reals
CenterX
CenterY
Create an actor of any small size (12x12) drag it to your stage and place it anywhere. Then constrain to the center of the scene.
Uncheck Moveable
Uncheck Visible
Check Fixed Rotation
Assign these 4 blocks to Dummy Center Actor
Constrain Attribute
self.position.X to scene.camera.origin.X + (half of the Width of the Scene)
Constrain Attribute
self.position.Y to scene.camera.origin.Y + (half of the Height of the Scene)
Constrain Attribute
game.CenterX to self.position.X
Constrain Attribute
game.CenterY to self.position.Y
Now you have usable Center coordinates which can be used by all spawned or current actors.
This does not have to be in the center of the screen.. Lets say you have a Control area on the bottom of the screen.. and an information bar at the top.
You could create 2 such Dummy actors (dont forget to add another pair of Game reals) which represent the center of those two areas. Then your Spawns only need to be set up adding or subtracting just the X or Y coordinate from the Dummy.
This process will just save you a little Math when trying to have items pop up during your game.
Hope this Helps..