How do I make text instances appear in an order

Get help using Construct 2

Post » Mon Jul 07, 2014 8:15 pm

Greetings

I have a text object with 3 instances, UID 0,1 and 2. I would like when I tap the screen to see the text with UID 0, if I tap again I would like to see text with UID 1 as well as keeping 0 visible, and last with UID 2 for another tap, so in the end after 3 taps all instances would be visible.

I used the following but it didn't work :(

Image


Would appreciate help, thanks!
Black Bobby The Hole Greenlit with 303 votes.
B
36
S
8
G
1
Posts: 163
Reputation: 3,029

Post » Mon Jul 07, 2014 11:12 pm

I was able to get the effect you want with this setup:

Image

In this case I setup the TextVisibilityPerPage variable like you did to -1. Event #2 is a touch event that you would tie to your background tile (I have it going on any touch event) which adds 1 to the variable.

Event #3 is on the text_main object that checks an instance variable called "visibility" against the TextVisibiltyPerPage global variable and if it matches then it sets the visibility of the object.

To set this up I created three instances of the text_main object on the page and added an instance variable called "visibility" setting it to 0 for the first one, 1 for the second, and 2 for the third. The reason why I used an instance variable is because I couldn't find a way to compare the built-in UID variable of an instance in a condition. Also actions work against the object, not the instance so when you're comparing text_main.UID you're comparing the instance but the action will work against all objects. Or something like that. When I first set it up all three text objects would appear.

Also this just sets them to visible so you need to deal with setting them to invisible as well.

As a side effect I found it you add another event where you're comparing "visibility" to be not equal to TextVisibilityPerPage and an action of setting text_main to invisible, it has a toggle effect, each time you tap on the screen the first one appears, then the first one vanishes and the second one appears, then the third. Probably an easier way to do this but it was an interesting discovery.

Hope that helps.
B
17
S
5
G
2
Posts: 39
Reputation: 1,846

Post » Tue Jul 08, 2014 9:20 am

I will try this when I get home, thank you very much.

One thing I am unsure of though, as I saw the basic tutorial with the guy shooting aliens, the author made so that every alien has 5 hp via instance variables. So if I were to choose 0,1 and 2, wouldn't all 3 text instances have only 1 instance variable value at the end? 2 to be more precise?
Black Bobby The Hole Greenlit with 303 votes.
B
36
S
8
G
1
Posts: 163
Reputation: 3,029

Post » Tue Jul 08, 2014 9:44 pm

It worked out great, thank you very much. Also that side effect you wrote about...it's great :D .
Black Bobby The Hole Greenlit with 303 votes.
B
36
S
8
G
1
Posts: 163
Reputation: 3,029

Post » Wed Jul 09, 2014 3:04 am

Je Fawk wrote:It worked out great, thank you very much. Also that side effect you wrote about...it's great :D .


Glad it worked out for you! Sorry, couldn't post a .capx at the time but happy it solved your problem.
B
17
S
5
G
2
Posts: 39
Reputation: 1,846


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot] and 17 guests