Onclick+Every x Second

1 favourites
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • HI

    I am making a game(you probably guessed).

    I want to set 3 options before you play.

    ---Easy-----------Normal-----------Hard-----

    The dragon----- The dragon-------The dragon

    fires every-----fires every------fires every

    3 seconds--------2 seconds ------1 seconds

    But I cant seem to find how to make an event for it.

    ON clicked-Every x seconds/doesn't work

    ON clicked

    Sub event-Every x seconds/doesn't work

    I've even done in stance variable but that doesn't work either.

    e.g.

    On "easy" clicked-Add 1 to "fire rate"

    On "fire rate"=1(I don't know how to do this one)(but I'd like it to be like every 3 seconds dragon fires)

    I'll really appreciate some help,

    Thanks in advance,

    SHIRATSUYU

  • You can use every X seconds where X is a variable equal to 3, 2 or 1 depending on difficulty. So if user starts the normal game, set the variable to 2. Automatically the event will be every 2 seconds.

  • hey lionz thank for the reply

    right ill be checking that out rn

    SHIRATSUYU

  • lionz

    umm it doesnt work

    ive set the dragons instance variable to name-x initial value-0

    ive done

    on button clicked-add 1 to (dragon)"x"

    and then

    dragon"x"=1

    every 1 second(both in same event)- action -dragin spawn fireball

    but no fire ball comes out at all

    Have i over looked anything?

    SHIRATSUYU

  • It's unclear what you are trying to do with both on clicked and every X seconds at the same time. I thought your issue was modifying the number of seconds. What do you mean by on click and every X seconds ? Do you mean while mouse button is being held down then every X seconds it should fire ? When you click the mouse it should toggle on firing mode for the dragon until you click again ?

    Note in general you can't use them both together regardless of what you are trying to do because on clicked is a trigger once event so the every X seconds will not keep running constantly inside it. So really depends what you are tryin to achieve with the gameplay.

  • lionz

    Really sorry about my bad English.

    I'll tell you what I mean in points(easier for me).

    .It is a 1 player game

    .The menu has 3 button choices easy,normal&hard

    .Easy-The dragon fires every 3.0 seconds

    .Normal-The dragon fires every 2.0 seconds

    .Hard-The dragon fires every 1.0 seconds

    .You control an owl

    .Your enemy is a dragon

    .The dragon is a bot

    .It is programmed to fire every x seconds

    I want to find out how to-

    #Make an event that sets the amount of seconds the dragon fires depending on what choice you picked on the menu

    My problem is-

    e.g.

    *I made an instance variable for the dragon named "firerate"

    *The initial value is 0

    *On"Easy"clicked add 3 to "firerate"

    Then I made an event

    e.g.

    *Compare instance variable-"firerate"= 3

    *Another condition(same event)Every 3.0 seconds

    *The action-Dragon spawn "fireball"on so and so

    The problem is that when I previewed the layout(nothing wrong with the layout)the fire balls didn't spawn at all

    I also tried sub-event/didn't work

    I really really hope you understood

    I'm poor at English

    I welcome any help and appreciate it

    Thanks in advance again

    SHIRATSUYU

    And whoops looks a lot of writing sry

  • Ok you meant click menu that makes more sense. So you just need an event that dragon fires every <variable> seconds, just this one its own, and when you click easy SET the variable to 3 like I mentioned above. Also use a global variable for firerate.

    So you have every <variable> seconds : spawn fireball, that's the event.

  • Hey lionz

    Thanks for the reply I'll be trying it out rn

    SHIRATSUYU

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • lionz

    I honestly still can't find how to do that

    Would you absolutely mind at all if you give an exaple

  • An example won't help here as I already described it and it is a single event. Let's see a screenshot of what you did and what is not working.

  • Hey lionz

    I'm really sorry

    Please find attachment

    The fire balls still didn't spawn:(

    Best

    SHIRATSUYU

  • Well you are loading a game after setting the variable so that can't be good. Also the event for the shooting should be every <seconds variable> seconds, use the variable and it is one event. The reason it's not shooting is because you're loading a game where the variable is set to 0 most probably. Or maybe you meant to save the game instead of load it ?

  • Hey lionz

    That's just it.

    I can't find the option for every variable seconds.

    SHIRATSUYU

  • In every X seconds where you write a number instead write the name of the variable. You didn't use a global so it will be dragon.seconds

  • Hey lionz

    Thanks for the reply.

    I'll be checking it out rn.

    Thanks,

    SHIRATSUYU

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