dop2000's Recent Forum Activity

  • Could you share a screenshot of your events? Just to make sure that you are doing everything correctly.

    I guess you can try a stress-test. Change your code, so that if AJAX loads the file successfully, the game exits. If "On error" is triggered or AJAX.lastdata is empty, display some debug information and don't exit the game.

    Then set up Windows Scheduler to run your game every few seconds. Or create a batch file RunAgain.bat :

    MyGame.exe
    timeout /t 10
    RunAgain.bat
    [/code:c9t5koy0]
  • There are third-party services that can be used to host leaderboards. (Don't ask me how they work though, I haven't tried any of them)

    Here are a few links:

    https://www.scirra.com/tutorials/1465/l ... rse-plugin

    https://www.scirra.com/store/royalty-fr ... ebase-2609

    plugin-firebase_t121776

    plugin-firebase_t91232

    There may be more examples in the Tutorials section, search for "leaderboard":

    https://www.scirra.com/tutorials/all

  • Did you put "Set StartTime to time" at the "On Start of layout"?

    Then yes, it will be very close to 0 when you launch the game. (because "time" starts from 0)

    Every time this layout is restarted, StartTime will be updated to current time.

  • R0J0hound

    You are right, thanks!

    I learned it the hard way that events like "On timer" can sometimes pick several instances, this made me a bit too cautious.

  • The main error is that when you return to "Game Level4" the second time, your variables are not reset. "Level" variable still contains value 4, so event #31 changes layout back to "Screen 5".

    To tell you the truth, I don't understand what's going on in your game, all these layouts constantly changing.

    Screen 5 goes to Level 4, Level 4 goes to Level 2, Level 2 to Level 3, then back to Screen 5, then back to Level 4...

    There's probably some logic to it, but I don't get it.

    Try adding "Set Level=1" at the start of Screen 5 layout. Maybe it will help, but I don't know if this can break something else in your game.

  • Ok, so the first problem is that "Wait 4 seconds, Go to next layout" is triggered twice, you should probably fix it.

    But the reason why Level4 is skipped is event #31 in "Screen 4 Game Levels". When you return to Level4 the second time, Level variable is already 4, so this event immediately changes layout back to "Screen 5".

  • Thanks!

    It's hard to understand the logic behind your events, but I believe the problem is in "Screen 5 ES Q3" at event #6.

    It's triggered two times (probably because the collision happens twice).

    So this code is executed twice: "Wait 4 seconds, Go to next layout"

    As a result, your "Level 4" layout is loaded very briefly and then next layout is loaded, which for some reason is "Screen 5".

    If you open console in your browser you will see it:

    Go to layout: Screen 5

    Go to layout: Screen 5 Q2

    Go to layout: Screen 5 Q3

    Go to layout: Game Level4

    Go to layout: Screen 5

    I suggest you use "Go to layout Game Level 4" instead of "Go to next layout".

    Also, you can add Browser object to your project and use Browser->Log to output debug messages. This is how I found out that event #6 is triggered twice.

    EDIT: no, wait, "Go to layout Game Level 4" doesn't fix it.. I need more time.

  • What I do not understand is why when I refer to an instance variable it doesn't take into account for each individual instance's unique variables. I am under the impression that there is a universal solution for getting the system to make instances behave independently based on their uniquely different variables.

    When you refer to instance variable, the system actually does this "for each picked instance".

    Say, if you do "Gun set var to random(10)", a different random number will be set for each instance of the Gun.

    And if you do "Gun set scale to var", they will all become different sizes.

    As for the Timer - this is not a workaround. This is the right way to do things in C2 when you are dealing with multiple instances and delayed actions.

    If you only have 1 gun, you can use "Every x seconds" or "Wait", no problem.

    If you have multiple instances of gun and they are firing/reloading at different times, it may be really difficult to get them working correctly with all these "Every x seconds", "Trigger once" and "Wait" events.

    In your last capx the problem is with the "Trigger once" condition.

    After one gun has fired, event #5 is triggered, all good. Then a second gun fires, but the first gun still has Cycling=1, so this event will not be triggered, because it's still true and it has already triggered once.

    And then the first gun fires again, but event #5 is still true, so it's still not triggered and now both guns are stuck with Cycling=1.

    Here is a simple solution:

  • Your event "Every gun.interval seconds" only makes sense if there is 1 gun instance.

    When there are many guns, this event will not work as you expect. I believe it compares "interval" for the first instance only, but it doesn't do picking, that's why all your guns fire at the same time.

    Here is the way to do what you want without the timer:

    This event will pick one or several instances of the gun, only those that satisfy the condition (nextShot<time). Picked guns will fire and a new value will be set to their nextShot variable.

    Most events of the Gun object will pick Gun instances. For example "Gun->Compare instance variable", or "Gun->Is visible".

    Any sub-events or actions under this event will only apply to picked instances.

    Most events of the System object don't do picking (except for those that start with "For each" or "Pick").

    For example "System->Compare two values Gun.NextShot<time" will compare values, but it will not pick gun instances. So if you do Gun->Spawn bullet in this event, all guns will fire.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add a couple of variables (global or instance) LastKillTime, MultiKillCount.

  • Use Timer behavior, it's perfect for this task:

    You can add a sub-event to "On timer" to check if the gun is reloading and only spawn bullet if not reloading.

  • Create a variable "StartTime", set it to "time" on start of the layout.

    Then change your event to this:

    System-> Compare two values -> (time-StartTime)<=10

dop2000's avatar

dop2000

Member since 26 May, 2016

Twitter
dop2000 has 259 followers

Connect with dop2000

Trophy Case

  • 8-Year Club
  • Entrepreneur Sold something in the asset store
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Forum Wizard Made 5,000 posts in the forums
  • Forum Unicorn Made 10,000 posts in the forums
  • x5
    Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • Unrelenting Visitor Visited Construct.net 180 days in a row
  • Continuous Visitor Visited Construct.net 365 days in a row
  • RTFM Read the fabulous manual
  • x3
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x13
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

28/44
How to earn trophies