[SOLVED] Setting text of multiple instances of a sprite font

Get help using Construct 2

Post » Thu May 29, 2014 5:54 pm

So I use the same sprite font on two layouts. I set the text in an external event sheet and include it in both. Therefore, saving duplication.

However, the text is set in on one screen but not the other.

Is there some kind of weird bug where set text gets locked to an instance of a sprite font?
Last edited by TheWyrm on Thu May 29, 2014 8:26 pm, edited 2 times in total.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu May 29, 2014 6:09 pm

So confirm the first layout I start works the other doesn't. I think this is a bug in C2.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu May 29, 2014 6:19 pm

When are you setting the text? It needs to be set on Layout2's event sheet. Layout1 won't affect Layout2's objects.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Thu May 29, 2014 6:37 pm

So I have the following simplified setup: Layout1, Layout2, Layout1Eventsheet, Layout2Eventsheet, SetTextEventSheet.

Layout1Eventsheet contains the specific mechanics for Layout1.
Layout2Eventsheet contains the specific mechanics for Layout2.
SetTextEventSheet sets text for SpriteFont1.

Layout1 and Layout2 contain an instance of SpriteFont1.

Layout1Eventsheet and Layout2Eventsheet include the event sheet SetTextEventSheet.

The reason why I do this is so I can avoid duplication of events. Write it once change it once.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu May 29, 2014 6:53 pm

That's fine, but Layout2EventSheet needs to invoke whatever the code is in SetTextEventSheet to set SpriteFont1. Typically done in On start of layout. What is the trigger that calls SetTextEventSheet?
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Thu May 29, 2014 7:00 pm

I basically have a count down shared between layouts. There is nothing but the include in layouts eventsheet to call the SetTextEventSheet.

Within the SetTextEventSheet I call set text every second.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu May 29, 2014 7:03 pm

Can you post a CAPX?
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Thu May 29, 2014 7:09 pm

I created this one.

http://www.FilesOverMiles.com/07e4235ae ... a9bb45ed2e

However, as you can see it works. So I must be doing something stupid.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu May 29, 2014 7:52 pm

It's a strange one. It just starts working after I flick between the layers a few time.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu May 29, 2014 8:28 pm

So I found out the problem. Its nothing to do with the sprite font. Its to do with a global variable for some reason being set as NaN instead of 0. I'll start a new thread for it.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests