Quick question about toggle buttons

Get help using Construct 2

Post » Thu Aug 07, 2014 6:36 am

Here. By the way there is a third party "toggle switch" behaviour which might be worth looking into. I haven't used it.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 07, 2014 6:45 am

Download beta relase r176 here

How you planning on storing this data?
Here is attached a small demo I did a year ago - lol. Its very messy... but might help - shrugs


Edit: Oh, wow, this demo was long ago - ha ha, anyways, if you touch the text at bottom it checks if shield is in the array... returns -1 if it isn't in array...meaning if the option is select/on then it returns numbers, else -1. I was playing around with various ways back then. The shield check is hard coded on line 7
You do not have the required permissions to view the files attached to this post.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Thu Aug 07, 2014 4:30 pm

Is this something that the "append text" feature might solve?
B
6
Posts: 30
Reputation: 292

Post » Thu Aug 07, 2014 9:38 pm

discoverthecurse wrote:Is this something that the "append text" feature might solve?


Yeah, you can do that. Just append it, or this is probably neater and more functional...
Create an instance variable called state
And set instance variable to either "On"or "Off"
And set text to "Bonus Chest: " & state
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Fri Aug 08, 2014 11:13 am

With this you can add any number of buttons with no more code :)

Edit: I didn't really explain how to use the capx very well. I've also simplified it--the family wasn't necessary.

First

1. Copy the btntxt object to your project
2. Copy the 1 event to your layout (no changes required)

Then repeat these steps for each button you need:

1. Drag a 'btntxt' onto your layout
2. Set its text in the "my_text" instance variable (e.g. "Bonus Chest: ")
3. Set its 'on' text in the "on_text" instance variable (e.g. "Normal")
4. Set its 'off' text in the "off_text" instance variable (e.g. "Easy")
You do not have the required permissions to view the files attached to this post.
Last edited by codah on Sat Aug 09, 2014 11:28 am, edited 3 times in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Aug 08, 2014 3:42 pm

:D Nice. I'll to look into everyone's latest ideas and see how they all do. Thanks for the continued replies! :D
B
6
Posts: 30
Reputation: 292

Post » Sat Aug 09, 2014 10:32 am

DUTOIT wrote:
discoverthecurse wrote:Is this something that the "append text" feature might solve?


Yeah, you can do that. Just append it, or this is probably neater and more functional...
Create an instance variable called state
And set instance variable to either "On"or "Off"
And set text to "Bonus Chest: " & state



I tried this and I am getting an error message:
Image
According to Scirra's Expression page my syntax seems to be right but I isn't working. I don't know what I am doing wrong. Any suggestions?
B
6
Posts: 30
Reputation: 292

Post » Sat Aug 09, 2014 10:41 am

@discoverthecurse

I'm assuming bcstate is an instance variable, in which case you with need to do ObjectType.bcstate instead as just bcstate by itself makes Construct 2 look for a global variable.
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864

Post » Sat Aug 09, 2014 11:14 am

@disconverthecurse I have updated my above post with instructions for using the capx, if you're interested
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Aug 09, 2014 11:55 am

I tried that and it let me click done but when I preview it changes it to "Bonus Chest:" and doesn't add the state. I am so lost. :lol:

@codah Im going to try implementing your system now. Thanks
B
6
Posts: 30
Reputation: 292

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 61 guests