GML Space Rocks Tutorial

Discussion in 'Programming' started by McSpooky, Dec 29, 2018.

  1. McSpooky

    McSpooky Member

    Joined:
    Oct 21, 2018
    Posts:
    2
    Sorry if this was mentioned, I did some searches but was unsuccessful
    I was running through the GML version of the tutorial for space rocks and run into a problem with splitting the rocks when you shoot them.
    The code provided in video and tutorial window results in an error. I know it happens when it tries to create a new instance and change the variable for the rocks to pick medium for a big rock and small for a medium rock. But I do not understand why or how to fix it.
    I get this error :


    this is the code, I hope someone can help/explain to me what is wrong here. Thanks

    Code:
     with (other)
    {
    instance_destroy();
    if (sprite_index == spr_asteroid_huge)
        {
        repeat(2)
            {
            var new_asteroid = instance_create_layer(x, y, "Instances", obj_asteroid);
            new_asteroid.sprite_index = spr_asteroid_med;
            }
        }
    else if (sprite_index == spr_asteroid_med)
        {
        repeat(2)
            {
            var new_asteroid = instance_create_layer(x, y, "Instances", obj_asteroid);
            new_asteroid.sprite_index = spr_asteroid_small;
            }
        }
    repeat(10)
        {
        instance_create_layer(x, y, "Instances", obj_debris);
        }
    }
    
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,547
    That simply means you don't have a sprite named spr_asteroid_huge. Add it.
     
  3. McSpooky

    McSpooky Member

    Joined:
    Oct 21, 2018
    Posts:
    2
    Jeesh so simple. never saw the mistype in my sprite naming. Thanks .
    :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice