help with switch statements

Discussion in 'Programming' started by confusedperson, Feb 10, 2018.

  1. I went along with a tutorial for unlocking levels which was made in 2013. hopefully not much has changed and I just made a mistake on my behalf however the error reads:

    Variable obj_levelsystem.level(100007, -2147483648) not set before reading it.
    at gml_Object_obj_levelsystem_Create_0 (line 4) - case 0:

    and my coding for the create event is:

    image_speed = 0;
    switch(level){
    case 0:
    image_index = 0;
    break;

    case 1:
    image_index = 1;
    break;

    case 2:{
    image_index = 2;
    break;

    I am very new to game maker and I hope I can continue in the future with your help. thank you in advance.
     
  2. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    3,241
    How does your object know what "level" is suposed to be? You haven't set it anywhere.
     
    confusedperson likes this.
  3. Niels

    Niels Member

    Joined:
    Jun 22, 2016
    Posts:
    829
    Your "level" variable controls your switch, and it seems like you haven't initialized that variable before the switch.
     
    confusedperson likes this.

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