+1 damage every seconds

Get help using Construct 2

Post » Fri Jan 27, 2012 3:18 am

i want to do a charge shot from the tutorial but i cant find the proper way to add damage the more i charge. any help?

charging
B
6
G
1
Posts: 44
Reputation: 1,220

Post » Fri Jan 27, 2012 3:28 am

There are a few ways to do something like this.

I presume you are wanting to hold a button of some sort, so you can do something like:

Player holds button
------ Set globalvariable.playerdamage to globalvariable.playerdamage + 1 * dt

Player releases button
------ Set globalvariable.projectiledamage to globalvariable.playerdamage

Projectile collides with enemy
------ Minus (globalvariable.playerdamage / 10) from variable.enemyhealth


By adding 1 each tick (using DeltaTime (*dt)) will give you a large number after a few seconds. You can divide this my 10 or 100 or whatver amount suits your damage scale. You can limit the maximum charge amount by adding extra conditions to the "player is holding button" event, such as "globalvariable.playerdamage is less than 1000".

Hope this helps.


~SolSoldjahBoy2012-01-27 03:28:59
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Fri Jan 27, 2012 3:31 am

You should only use the instance variable Damage of bullet, not the global var.

Quickly commented fixed capx
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Fri Jan 27, 2012 3:34 am

cool it work ty

B
6
G
1
Posts: 44
Reputation: 1,220

Post » Fri Jan 27, 2012 3:39 am

and if i want to make it stop at 5 damage how i should do it?
B
6
G
1
Posts: 44
Reputation: 1,220

Post » Fri Jan 27, 2012 3:43 am

Add another condition in the event 3 "Sprite2.Damage < 5"
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Fri Jan 27, 2012 3:45 am

You could add the following event:

Condition: instance variable is greater than 5
Action: set the instance variable equal to 5.

edit: @kyatric - you're fast with the replies!stemkoski2012-01-27 03:46:19
B
61
S
18
G
14
Posts: 50
Reputation: 18,592

Post » Fri Jan 27, 2012 3:46 am

nvm i got it
B
6
G
1
Posts: 44
Reputation: 1,220

Post » Fri Jan 27, 2012 3:48 am

oh i did it a different way,i said condition

charge shot= 1     set charge shot=0
every 5 seconds

i guess your way is better
B
6
G
1
Posts: 44
Reputation: 1,220


Return to How do I....?

Who is online

Users browsing this forum: makkancs, Matthew de and 36 guests