YesNoOk
avatar

ScreenPos (Triggers) (Read 5743 times)

Started by JustNoPoint, October 19, 2015, 02:09:46 am
Share this topic:
ScreenPos (Triggers)
#1  October 19, 2015, 02:09:46 am
  • ******
    • www.justnopoint.com/
Gets the value of the player's absolute (screen-relative) position. You must specify the component that you want to check, eg. "Pos Y" to check the Y-position.

Format:
Pos [component]

Arguments:
[component]
X, Y

Return type:
float

Error conditions:
none

Details:
For "ScreenPos X", the value is relative to the left of the screen (value 0). Negative is left, positive is right.

For "ScreenPos Y", the value is relative to the top of the screen. Negative is above the screen, positive is downward.

Example:

Quote
trigger1 = ScreenPos Y >= 0 && ScreenPos Y < GameHeight
  True when the player's is in the screen's vertical extent.
Re: ScreenPos (Triggers)
#2  October 19, 2015, 03:50:25 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Player's and helper's Y positions are always relative to the floor, which varies from stage to stage.

If for whatever reason you need to move / offset your character relative to the screen, you can use the ScreenPos trigger to translate that.

Code:
postype = back
Y = Floor(-ScreenPos Y + 60)

-ScreenPos Y will align the Player's axis to the very top of the screen.  Then you just add to it as necessary.  So in the above example, the player will be positioned 60px from the top of the screen.

Code:
postype = back
X = Floor(GameWidth/2)
Y = Floor(-ScreenPos Y + (GameHeight/2))

This will position your character in the center of the screen.