O Ilusionista
Captain 100K
This is a code I did and I want to share.
Using this code, you can position any entity centered on the screen, using the half of the screen size (any) and the middle of the playable area. The "+1" on the code is to avoid division by 0 (on 2D stages)
Using this code, you can position any entity centered on the screen, using the half of the screen size (any) and the middle of the playable area. The "+1" on the code is to avoid division by 0 (on 2D stages)
Code:
void bmtcenter()
{ // centers the entity on the screen
// O Ilusionista - 06/10/2014
void self = getlocalvar("self"); //Get calling entity.
int Screen = openborvariant("hResolution")/2; // Get screen width divided by 2
int XPos = openborvariant("xpos"); // Get camera x position
int Width = openborvariant("PLAYER_MIN_Z")+(openborvariant("PLAYER_MAX_Z") - openborvariant("PLAYER_MIN_Z"))/2; // Get playable area size center
changeentityproperty(self, "position", Screen+XPos, Width+1, 0);
}