Hi, can you help me find a way to fit the crosshair into the desktop and prevent it from stretching too much?
My game is 640x360 in size.
When I aim, it stretches too much and always ends up outside the screen.
Iâm guessing this only happens when you move the mouse to the left of the screen, and when moving the mouse to the right itâs ok?
Are you repositioning the cursor image when itâs width is changed? If not, then as you move the mouse to the left, the image is increased in width and the centre of it moves to the right. This magnifies or increases the distance between the centre and mouse pointer. Hereâs whatâs happening visually (the red line is the distance from the object centre to the cursor:

Yes, itâs corrected to the right, and it works fine, but if I aim at other positions, I get the problem.
So, do I have to resize the cursor width? In what event do I have to intervene?
Do you want the crosshair to just stretch towards the side of the mouse, or to resize but stay centred?
If you want it to stretch, then I think youâll need to use the Hitboxâs origin instead of the centre (assuming itâs at the top left of the image) - AngleBetweenPositions(Playerhitbox.X(), Playerhitbox.Y() - 5, MouseX(), MouseY())
If you want the crosshair to stay centred on the screen while stretching, then youâll probably need to change the Playerhitbox origin to the centre of the image.

![]()
It already remains centered on the player.
I entered center(x)(y) to (x)(y) as mentioned,
but Iâd like to know how I can set a limit so that it doesnât go beyond the edge of the screen when the player extends to aim.
Can anyone help me? How can I set the maximum amount of crosshairs that extends to the end of the screen?
I made a mistake in this post - it should have read DistanceBetweenPositions(Playerhitbox.X(), Playerhitbox.Y() - 5, MouseX(), MouseY())
You could add an action after you set the width of the mirinocursore to set the width to min(mirinocursore.Width(), ScreenWidth()/2) (see note below). I think that should keep the cursor width to 1/2 the screen.
Note - you could just have one action to set the width, though itâs a bit harder to read: min(DistanceBetweenPositions(Playerhitbox.X(), Playerhitbox.Y() - 5, MouseX(), MouseY()), ScreenWidth()/2)
I finally figured out where my problem lies, but I still havenât been able to solve it.
All the game sprites are in the game layer, while I use the base layer for the HUD.
At the beginning of the scene, I set a zoom that halves the screen size, and this causes the cursor to always go off-screen.
How do I enlarge the cursor by calculating the zoom?
The issue is the mix of a scaled layer and a non-scaled base layer.
Youâre getting the position of the Playerhitbox object, which is on the scaled layer âgameâ, and checking the mouse position which is on the unscaled layer âbase layerâ. This is really screwing up the calculations, and itâs a bit of a mathematical nightmare to work it all out.
So I went the simple route, and used the mouse position on the layer âgameâ. I also changed the layer of the bomb to âgameâ, otherwise it too would need complex calculations to position and target correctly.
Teaser and explanation on what I did:

I added a variable named ratio. This is to cater for the difference in the mirinocursoreâs sprite width and the distance between the origin and LandingPoint. An explanation why:
Say the sprite width is 100 pixels, and the distance between the origin and LandingPoint is 80 pixels, or 80% of the spriteâs width. If the mouse moves to 200 pixels away, the sprite is enlarged to 200 pixels, and the LandingPoint is 160 pixels from the origin - 40 pixels short of the mouse.
By setting the ratio variable to width/(distance between origin & LandingPoint) (or 100/80 = 1.25), we can use this value to multiply the width so that the LandingPoint is actually at the mouse position. So if the mouse is 200 pixels away, multiplying that by 1.25 gives us a width of 250 pixels. Since the LandingPoint is 80% of the way across, itâs position is now 80% of 250 = 200 pixels.
Here are the modifications I made to get it to work:

Why does the cursor disappear? Where am I going wrong?
If I disable the âcrosshair cursorâ width and angle events, it reappears.
Because the point names are case sensitive. Itâs LandPoint, with a capital âPâ, meaning PointX(âLandpointâ) = 0 and leaving ratio as a large number:
![]()
Oh, how careless! Thank you so much.
One last question: What if I wanted to replicate the same thing for touch controls? I initially developed the game for the mobile version and am now converting it to PC as well.
How can I extend the object to the end of the screen?
In this case, the joysticks are already in the base layer.
Are you using a MultiTouch Joystick object? If so (and say itâs named âMTJoystickâ) maybe change the mirinolancio width to MTJoystick.StickForce() * ScreenWidth() / 2.
Yes, I initially developed the game for mobile, but I donât use any extensions. The joystick code is the one shown above, and the force variable isnât recognized.
Ah, ok, I didnât spot that screen shot. Then try changing the mirinolancio width to (min(RightButtonBackgroud.Distance(RightButton) / RightButtonBackgroud.Variable(Joystick.JoyDinstanceMaximum), 1) * (ScreenWidth() / 2).
So what thatâs doing is finding the ratio of the RightButton position to the maximum distance (limiting it to 1) and multiplying that ratio to half the screen width.
so it goes too far off the screen and if I move the joystick towards the center it doesnât get smaller but remains enlarged








