Tower upgrading

This forum is currently in read-only mode.
From the Asset Store
C3 Swipe Towers is the game of speed and reflexes by enabling climber reach the top of tower.
  • I going to make a tower defense game with upgrades. This what I Put so far for my event sheet

     Sprite [Level = 1][Attack = 50]
    [/code:1927j5s5]
    
    [code:1927j5s5]1. [on "button" clicked] -> [+new action]
    sub-event
    2. ["Sprite" Value "Level" Equal to 1] -> ["Sprite": Add 50 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
    3. ["Sprite" Value "Level" Equal to 2] -> ["Sprite": Add 100 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
    4. ["Sprite" Value "Level" Equal to 3] -> ["Sprite": Add 200 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
    5. ["Sprite" Value "Level" Equal to 4] -> ["Sprite": Add 400 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
    6. ["Sprite" Value "Level" Equal to 5] -> ["Sprite": Add 800 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
    [/code:1927j5s5]
    
    What should i change,add,or delete. Because every time i tested the game, its level jumps to 6
    Thanks!
  • This is due to your order of events.

    In event 2, Level is equal to 1. One gets added to Level. Level now equals 2.

    In the next event, Level equals 2, because you changed it already in the previous event. So it meets the condition for "Level equal to 2" and the event triggers, which adds 1 to Level. Now it equals three.

    In the next event the same thing happens. And so on down the list until you hit six.

    So, you could do this a few different ways. The first is you could add another criteria to your conditions to keep them from triggering all in the same tick. I would make another variable called "switch" or something like that, that turns On when you click the button, and turns Off when you level up. That way you can check Switch in your conditions, and if it is Off, then the level-up action won't run. Like this:

    +On button clicked
      -> Set Switch On
        + Sprite Level = 1
        + Switch = On
          -> Level up
          -> Set Switch Off
        + Sprite Level = 2
        + Switch = On
          -> Level up
          -> Set Switch Off
    
    Etc.
    [/code:puxsx5mi]
    
    The second way you could do this is to reverse the order of your level code.  So it would look like this:
    
    [code:puxsx5mi]
    + On button clicked
      + Level = 5
        -> Set level to 6
      + Level = 4
        -> Set level to 5
    
    Etc.
    [/code:puxsx5mi]
    
    And finally, since it seems you are doing a really simple linear calculation to increase your levels, you could simply do this:
    
    [code:puxsx5mi]
    + On button clicked
      -> Add 1 to level
      -> Multiply Attack x 2
    [/code:puxsx5mi]
    
    And leave it at that.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Good Job!

    Do you have sample capx.?

    Thanks!:)

  • karlmahmen unfortunately this was made in Construct Classic so there likely won't be a CapX (construct 2 version). However, the coding style between Construct 2 and Construct Classic is very similar, so it should be fairly straight-forward for you to re-create in Construct 2.

    Hope that helps! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Jayjay Thanks!but iam developing a tower defense game in ios the problem is i cant get the logic of upgrading tower... im so noob :( help

    Thanks!:)

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