using variables and timers to control combos in a platformer

0 favourites
  • 3 posts
From the Asset Store
10 Retro songs ideal for platformers or farming games
  • hey all, I'm not technically a beginner but I'm still a novice when it comes to construct. I have a platformer that uses timers to control the input from the user during an attack animation. the "attack" timer is set 0.5 seconds and the structure looks like this

    [attachment=0:1pi82jmx][/attachment:1pi82jmx]

    i have global variables controlling the attacks but my question is would it be better to control the player with instance variables since these moves only apply to him. I plan on adding about 5-6 more combos, so would it be better to create a global variable, say called combo power up, to control the characters abilities as they are learned throughout the game. like: if global variable "attackpowerup" = 2 then add the 4th attack in the combo. just curious and any help would be much appreciated.

  • ashburp

    In my experience, it is always better to have variables local to the object using them and only use globals where there is no object which could logically contain them. Global variables always have the possibility of causing odd bugs. Plus these kinds of bugs can be extremely hard to debug. Even when using a variable that is manipulate by multiple types of objects (for example, health on both the player and enemies), I create a family and add the variable to the family. That way it still keeps the variable local to the group of objects using it.

    Not only does this protect against bugs but, when your project gets really large, you always know where to look to find the variable. If you have some instance variables and some global variables, it takes more effort to keep track of where to find them and what they do.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • okay, I plan on making a pretty decent sized game. I've just been making the characters move list and regular functions now (128 events). things are starting to get a little unorganized. I think I'll redo everything as instance variables since they only pertain to the one character and use a global variable to control the progress of the character in the game. Thanks for the help FragFather and for reminding me about families.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)