How do I create a global var "number of lives left system"?

Get help using Construct 2

Post » Thu Jul 10, 2014 4:00 am

Hello everybody, I have a question. If I have thirteen objects (like the hearts below) in a family/group, how would I make it so that every time the character's health hits 0, you would lose a heart or life. Then I'd make it so that when there are no hearts/lives left, you would have to start from the first level. Am I going about it the wrong way by put all thirteen hearts/objects into a family/group? How do I do this?

Image


Thanks,
guannstar (Fnord)
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Thu Jul 10, 2014 5:14 am

I would actually use a tiled background, then set the width to livesLeft * imageWidth, that way you dont have to deal with picking objects and annoying stuff like that
B
46
S
14
G
7
Posts: 603
Reputation: 8,106

Post » Thu Jul 10, 2014 2:07 pm

Sorry, is there a guide or something that can roughly show me how to do that? Do you know of any good tutorials? I think what you're saying, is exactly what I'm looking for:)
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Thu Jul 10, 2014 2:20 pm

Check the capx.
In your project change int(TextBox.Text) to your current number of lives left.
You do not have the required permissions to view the files attached to this post.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Thu Jul 10, 2014 3:59 pm

Thanks, this is very cool:) I try it and get back to you.
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Fri Jul 11, 2014 8:48 pm

Hi, I can't get the tiled background object to work either:( Two problems, the first is that I don't know how to take a specific width away from the tiled object. For example, see the highlighted section below... I can only "Set width" to 24 pixels, rather than subtract 24 pixels from the tiled object. The second problem is that every time I restart the layout, the size of the tiled object (the heart) reverts back to its original size, which defeats the whole purpose. Can somebody please please show me how to make a "lives left per level/layout" system using a global variable (so that the tiled object size wont refresh every time the layout does)?

Image
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Sat Jul 12, 2014 5:03 am

Bump, please I really need some help.
B
33
S
8
G
1
Posts: 624
Reputation: 3,771

Post » Sat Jul 12, 2014 9:48 am

To subtract you have to enter an expression like this.

Set Width to lifehearttiled.width-24 this get the current width and subtracts 24 from it.

To get this simply highlight the box where you enter the information. Click the object you are referencing in the "Objects With Expressions" pane and scroll down until you find width then double click it.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763


Return to How do I....?

Who is online

Users browsing this forum: rayolf, Yahoo [Bot] and 27 guests