GM:S 1.4 counter variable

Discussion in 'Programming' started by fxokz, Dec 27, 2016.

  1. fxokz

    fxokz Member

    Jul 3, 2016
    So basically i think image_speed is causing problems in my game so im trying to remove it by adding a counter variable instead. The problem is keeping track of multiple counters So far i have a variable in my create event called "counter" but what if i need more counters? do I have to keep initializing variables in the create event or is there a way to make it more easier?
  2. GRArthas

    GRArthas Guest

    you just make more variables in the create event with different names example: counter_imgSpeed but if you use these variables in more than one object you can either use global. for your variables for example global.counter or just make a script and put them all there and call them in the create event
    fxokz likes this.
  3. PWL

    PWL Member

    Jun 21, 2016
    You can also create an array of counters.
    I'm thinking something along these lines:

    /// CREATE
    for(var i=0; i<10; i++){
        counter[i] = 0;
    /// STEP
    for(var i=0; i<10; i++){
    And then add macros/constants that give a description for the numbers 0-9. That way you can get them like this:
    counter[COUNTER_IMGINDEX] = 0;

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