Tower Defence - this object [tower]

  • hello i'v made this TD game:

    *****://dl.dropboxusercontent.com/u/52790793/html5_games/Tower%20Defence%20vr%202.0/11.capx

    [change the "*****" to "https"]

    learn from the tutorials.

    i have 1 problem, i'v made upgrade button - but when i'm using it, its upgrading all the towers and not only the one i choose.

    how cani fix it?

  • Yes, the way you have it setup right now, you are "picking" every tower to add the upgraded level to.

    There's a few different ways to pick the correct tower you want to upgrade.

    One suggestion would be to create an instance variable on the button object. Lets call it "TowerUID".

    On line 3 where you spawn the upgrade button. set the TowerUID variable to "trt_basic.uid"

    eg: (btnUpgrade - set value "TowerUID" to trt_basic.uid

    This now lets the upgrade button know which tower it belongs to.

    Next, down on line 28 where you have the upgrade logic....

    You need to create a sub event that picks which tower to apply the upgrade to.

    So add a sub event and use "Pick by evaluate" -> trt_basic (as the object) and in the evaluate line put trt_basic.uid = btnUpgrade.towerUID

    Then for the action, move the 2 actions you have for the trt_basic (add 1 to level) and (set turret range), down to this new sub event, so that it only effects the "picked" turret.

  • Try Construct 3

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

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

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