• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Need help with random cursor

J

Joshua Hotchin

Guest
Hey guys,
So I have a sprite with 10 images, all different coloured cursors.
Here is my code:
Code:
if (room != rMenu) and (room != rControls) and (room != rUpdatesAndNotes) and (room != rShop) and (room != rEnding) and (room != rCredits)
{
    cursor_sprite = sCursorGun;
}
else
{
    cursor_sprite = sCursor;
    with (sCursor)
    {
        image_speed = 0;
        image_index = (choose(0,1,2,3,4,5,6,7,8,9));
    }
}
The idea is that every time a room is started the cursor is a random colour. At the moment the cursor keeps changing colours as if animated for the cursor is enabled.
The code is in a "oGame" object which controls the game and is inside the "Room Start" event. You can see here that I have set the image_speed to 0 and also in my sprite the image speed is 0.
Someone please help, it is probably something really simple that I mussed.
 

Mick

Member
What @IndianaBones said and also you can't control the image_speed o rimage_index of cursor_sprite. You could instead make a oMouse object and set x and y to mouse_x and mouse_y in the begin step event. Then your code would be:

Code:
if (room != rMenu) and (room != rControls) and (room != rUpdatesAndNotes) and (room != rShop) and (room != rEnding) and (room != rCredits)
{
    with(oMouse)
        sprite_index = other.sCursorGun;
}
else
{
    with (oMouse)
    {
        sprite_index = other.sCursorGun;
        image_speed = 0;
        image_index = (choose(0,1,2,3,4,5,6,7,8,9));
    }
}
You will need to have an instance of oMouse in all your rooms or have it set as a persistent object and create an instance at the start of the game.
 
Last edited:
J

Joshua Hotchin

Guest
I fixed it by doing:

cursor_sprite = choose(1,2,3,4,5)

And just made the sprites individual.
 
Top