Offscreen Enemy Indicators

  • 29 favourites



5,251 visits, 10,604 views



This tutorial hasn't been translated.


This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Keeping the indicators on-screen

Ok, every monster has an indicator on top of it now when it's offscreen but we can't see them. We need to keep the indicators within the viewable area.

We use the following expressions:





These expressions give the coordinates of the layer x at the left, right, top and bottom of the screen. So for example, if the layout was 640x480 and the window size was 640x480 then ViewportLeft(0) would be 0, ViewportRight(0) would be 640, ViewportTop(0) would be 0 and ViewportBottom(0) would be 480.

We'll also use the min(x,y) and max(x,y) expressions.

min(x,y) returns the smaller of the two values and max(x,y) returns the larger.

So, to limit the indicator's x value to the right edge of the screen we can use

    min(ViewportRight("Indicators"), Indicator.X)

That gives us the right edge of the screen or the indicators x value, whichever is smaller.

We can do the same thing for the left edge of the screen using the max formula:

    max(ViewportLeft("Indicators"), Indicator.X)

That gives us the left edge or the indicators x value, whichever is larger.

And combining the two:

    max(ViewportLeft("Indicators"), min(ViewportRight("Indicators"), indicator.X)

gives us a value somewhere between the left and right sides of the screen.

We don't want the indicator to be right at the very edge so we'll add a variable called 'indicatorDistFromEdge':

    max(ViewportLeft("Indicators") + indicatorDistFromEdge, min(ViewportRight("Indicators") - indicatorDistFromEdge, indicator.X))

We can do the same thing with the y value and ViewportTop/ViewportBottom:

    max(ViewportTop("Indicators") + indicatorDistFromEdge, min(ViewportBottom("Indicators") - indicatorDistFromEdge, indicator.Y))


And finally we want the indicator to point towards the enemy:

Add an indicator action:

All done

Here is the complete capx.


  • Order by
Want to leave a comment? Login or Register an account!