Best common practices in one place

0 favourites
  • 6 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • I wanted to clarify the conditions when trigger once while true is really needed. For example I had a situation where game created sprites and invisible sprites that had a touch trigger on them.

    Game went very slow and I realized that my condition was a global variable (Thisthing=1) and event was create object a (and b etc etc)

    Then I realized that it created them all the time and game became very slow. So I put there this trigger only once additional condition.

    It would be good to know when these are needed. For example if there is a condition that turns sprite to zero angle.

    (and it has done it). Does it still do it everytime or will the game just "see" it that the sprite´s angle is 0 and does not try to do the command.

    So in a nutshell: Is it more efficient to a) put there a additional condition: sprite angle <> 0 or is it faster to just let the game try to check the angle.

    Which one is more efficient in a game sense meaning which are the things and solutions that are faster than slower (sorry english is not my primary language)

    I wonder if we could actually make a list of common solutions that work better than the other and has the same kind of an outcome.

    For example: Which one is the best way to bring a sprite into a play. a) another object spawns it b) it´s already there hidden somewhere and it´s repositioned or c) create object

    Or:

    Set animation to default

    Then the animation is default. Should the game check it all the time and put the animation to default even though it already is or does the game check that: animation is already default and does not have an impact on it (does not do anything).

    I wonder if there are many conditions it would slow down. For example in the previous example. Should there be an extra condition:

    if animation is not default then set it to default.

    or just simply:

    set animation to default (no matter what, even if it already is default)

    Which one is a better practice?

    Yeah. Depends on the situation is probably the easiest answer but certainly people that have a lot of experience have a somekind of a feel that which way is the best to approach.

    So I think that we need those experienced solutions that game maker should try first. There are a lot of tips and tricks spread all around these forums and those tidbits should be put into a same place where they are easily found. Common practises or something like that.

    Like this way:

    All triggers should be on top of events

    All ticks should probably be on the same action

    Avoid too many sub-events

    Always create object and not use spawn object if possible (or vice versa)

    wait for 0 seconds (sometimes very useful even though not intuitive)

    What kind of conditions are best working when something occurs only once or all the time.

    Condition can be left empty!

    All kinds of stuff.

    etc. etc.

    Sure there are many of this info available but somekind of a experience must have been built that which solutions work faster than others.

    Sorry for my english.

  • I am sure that some common practises to make sure is not happening is to check how many sprites are spawned or created since if they come to same x,y it´s possible that there are many of them stacked one on another and game designer doesn´t see it.

    For example my example of: create object did just that. In human intuitive there was this thought that: Create object (if there is not already and only one) however the game can create them all the time if you are not careful.

    The conditions are therefore very important to see if they happen once are all the time.

    This is the main thing about my question here.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • With your conditions they will trigger every time they are true. If there is no condition in the event at all it will trigger all the time. The 'trigger once' condition is useful when you only want something to trigger a single time but you could achieve the same thing with a different approach. As a newbie I wouldn't worry so much about the 'one' best way to do things in C2. What is really important is how much work you are making the device do.

    The best common practice I can recommend is to get used to the debug window. It has a lot of useful information, including the object count (it would have shown the object count continually going up) and stats on how intensive events are based on its cpu consumption (shows you which events are causing slow down if you are experiencing it).

    Graphics are a different subject but this should be useful. https://www.scirra.com/blog/112/remembe ... our-memory

  • About

    Or:

    Set animation to default

    Then the animation is default. Should the game check it all the time and put the animation to default even though it already is or does the game check that: animation is already default and does not have an impact on it (does not do anything).

    Should not worry about that one. Because C2 will only set the condition to true when

    the new animation is different from the active animation or when the current animation stopped playing.

    This means that it does not hurt the system to set it on every tick, though there might be some very very minimal performance loss since it has to search if the animation name exists.

  • About

    All triggers should be on top of events

    That is a heavy story. Placing a trigger on top of a top level condition is (especially for beginners) a practice that can (and will) avoid a lot of 'logic' problems.

    Yet it is no rule. It is rather a lazy recommendation (i am that lazy too to recommencement this) because it is so difficult to explain.

    A trigger runs instantly, when it catches that event that it is designed to catch, no matter where it is coded in the sheet.

    If a trigger is buried deep down, as a sub event, it has to look up to find out if it can run. We are used to read the events top down, so a down up logic is hard to grasp, mostly. When the trigger meets an 'else' it gets stuck, by instance. So, the benefits (for beginners, including myself) of always placing a trigger on top beats a lot of problems. Yet, the advanced user surely knows how go along with it, but probably cant explain it well.

  • All right! Good answers here. I am trying to move the most used triggers (groups for Walk and Flying; sprite can move on ground or fly) since I am having this little problem. Everytime I click anything the game stops for a millsecond or so (blink of an eye). I wonder what is the cause for this. I wonder if it has something to do exactly what was discussed here: triggers and waiting to find things. Must check it out now.

    What other common practises are there we all should know better? What method is preferrable to other (with same kind of an outcome) I am sure there are a lot of these and only experienced designers can share their info. Hopefully.

    edit. This thread is already useful. It really helped!

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