A question about text and global variables

Just started using Construct 2? Post your questions here

Post » Sun Jun 15, 2014 9:25 am

What should I do to force the text to retrieve information from global variables? In events, I did:

System Every tick Text1 Set text to "Score: " & Score


Why doesn't it work?
B
4
Posts: 21
Reputation: 242

Post » Sun Jun 15, 2014 9:30 am

It does work. Did you save Score as text "" or number 0 because text will show nothing "" unless you put something in it and number should show 0.
Is your text box big enough to show Score: 0...
And don't use everytick, only update the text file when the score updates...

Post a capx, so we can see where you went wrong - because it does work.
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 » Sun Jun 15, 2014 11:09 am

Can you please explain more clearly? I am new to Construct 2.
B
4
Posts: 21
Reputation: 242

Post » Sun Jun 15, 2014 1:43 pm

And How should I do this the right way that it updates every time when global variable changes?
B
4
Posts: 21
Reputation: 242

Post » Sun Jun 15, 2014 2:19 pm

OK, here are the screenshots. I've got the Event Sheet and the Layout. Sorry for spamming messages if it annoyed you.
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 21
Reputation: 242

Post » Sun Jun 15, 2014 2:59 pm

if your global variable is a number then that is the reason I think. A number is a type called "number". The text object only takes data in the "text" format. If you want to use data of the type "number" in text you might need to surround the number with "str(...)" when you set the text. Like this:
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 41
Reputation: 762

Post » Sun Jun 15, 2014 3:48 pm

SadisticDentist wrote:And How should I do this the right way that it updates every time when global variable changes?

Hi, you have an event 'on collision with sprite6' you could update the text in tne same event.

ON collision with sprite6:
Destroy sprite6
Add 1 to score
text = "score " & str(score)
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
35
S
13
G
7
Posts: 363
Reputation: 7,283

Post » Mon Jun 16, 2014 8:24 am

It's still not working and (I think it's a bug) in 'Good job' layout, there are platforms (they are sprites, ofc) that I placed on 'Level' layout, but not on the said 'Good job' layout. The platform bug happens only when I play my game, but not when I'm editing it. Why is it this way?! :shock:

Getting back to my first question, here are the screens (one is the Event Sheet, the other one shows what the text is actually indicating when I play the game and the bug with platforms that shouldn't be where they are):
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 21
Reputation: 242

Post » Mon Jun 16, 2014 12:26 pm

Hi, if you post a capx, others will be able to help you much easier.

If you don't want to share your game, then make a capx that illustrates your problem. If we can't see what you are doing in your code then it is a bit hard to help. :)
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
35
S
13
G
7
Posts: 363
Reputation: 7,283

Post » Mon Jun 16, 2014 12:49 pm

try this and see
You do not have the required permissions to view the files attached to this post.
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,763

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: kainrazial and 2 guests