Skip to content

Stay On Screen

Move the object to keep it visible on the screen.

Authors and contributors to this community extension: 4ian, Bouh, D8H.


Force the object to stay visible on the screen by setting back its position inside the viewport of the camera.

The shoot'em up example uses this extension (open the project online).

Tip

Learn how to install new extensions by following a step-by-step guide.

Stay on Screen

Force the object to stay visible on the screen by setting back its position inside the viewport of the camera.

Behavior actions

Screen bottom margin
Change the bottom margin (in pixels) to leave between the object and the screen border.

Screen left margin
Change the left margin (in pixels) to leave between the object and the screen border.

Screen right margin
Change the right margin (in pixels) to leave between the object and the screen border.

Screen top margin
Change the top margin (in pixels) to leave between the object and the screen border.

Behavior conditions

Screen bottom margin
Compare the bottom margin (in pixels) to leave between the object and the screen border.

Screen left margin
Compare the left margin (in pixels) to leave between the object and the screen border.

Screen right margin
Compare the right margin (in pixels) to leave between the object and the screen border.

Screen top margin
Compare the top margin (in pixels) to leave between the object and the screen border.

Behavior expressions

Expression Description
Object.StayOnScreen::MarginBottom() Return the bottom margin (in pixels) to leave between the object and the screen border.
Object.StayOnScreen::MarginLeft() Return the left margin (in pixels) to leave between the object and the screen border.
Object.StayOnScreen::MarginRight() Return the right margin (in pixels) to leave between the object and the screen border.
Object.StayOnScreen::MarginTop() Return the top margin (in pixels) to leave between the object and the screen border.

This page is an auto-generated reference page about the Stay On Screen extension, made by the community of GDevelop, the open-source, cross-platform game engine designed for everyone. Learn more about all GDevelop community-made extensions here.