SpriteFont and Multiple Layouts?

New releases and general discussions.

Post » Sun Dec 02, 2012 11:33 pm

So it seems that most of the time whenever I try to change layouts in the event editor, I get some sort of crash. So far, this is the second time this has happened to me. The first time that it happened, I had actually gotten layout switching to work initially. Then after a bit of added new code here and there (not even touching the layout switching code btw), it suddenly crashes. I could not for the life of me figure out what was causing it, so I tried manually reverting my project back to a state when it did work by deleting all the new code I had added, which ended up working. Luckily I didn't have to remove much, and everything worked fine after that, but I was still never able to isolate what was actually causing it.

This time however, it's crashed right after I added the "go to layout" event for the first time. But the weird part about this is that even though it crashes most of the time, it will occasionally work. I've tried debugging it and it's telling me the crash is caused by the SpriteFont plugin that I'm using, though I have no idea why that's even the problem.

I've looked around the forums a lot, and it seems that a lot of other people are having trouble with layout switching as well. Though the problem usually ends up being something like having an OR condition run during layout switching, or using transitions. I am doing neither of those. At this point I'm pretty much convinced that this is some bug within CC itself, and not due to poor coding on my part. But I need to know if there's any way to fix/prevent this from happening, since the game I'm working on is going to need a lot of layouts. So just simply avoiding layout switching entirely is out of the question.Jimmy529052012-12-03 06:53:10
B
4
Posts: 5
Reputation: 360

Post » Mon Dec 03, 2012 12:11 am

Can you post the cap or at least a screenshot of the code that has to do with layout switching?

Also, check if removing the spritefont plugin fixes it for some reason.Gelidaer2012-12-03 00:13:57
B
13
S
4
G
1
Posts: 63
Reputation: 1,170

Post » Mon Dec 03, 2012 1:02 am

I might be misunderstanding what you're saying, but using the or condition is not a solution as it can cause crashes, so keep on not using it.

Are you using transitions? If so, don't.

The only other idea I have is to do what I do when trying to track them down - find a way to reproduce them every time, then with your project backed up, start deleting stuff until it stops crashing.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,422

Post » Mon Dec 03, 2012 1:50 am

[QUOTE=Arima] I might be misunderstanding what you're saying, but using the or condition is not a solution as it can cause crashes, so keep on not using it.

Are you using transitions? If so, don't.[/quote]

Whoops, I mistyped that; I meant to say that or conditions were a problem, not a solution. And no, I'm not using transitions.

[QUOTE=Gelidaer]Also, check if removing the spritefont plugin fixes it for some reason.[/quote]

Actually, I checked just now and it seems that the problem is in fact with the spritefont plugin. The weird thing though is that the problem didn't even occur until I had added another layout. I actually managed to fix the crash (somehow.. still not quite sure what I did to fix it), but now there are some pretty strange bugs with the spritefont plugin. Like, some of the text sometimes doesn't even show up in the original layout. But as I said, it worked perfectly fine before I added another layout. (I didn't even touch my original layout either when adding it) What's even weirder than that is that if I run my original layout on its own, it still bugs up a bit, as if simply having more than one layout suddenly causes problems. Removing the layout seems to fix the problem too.

Any ideas? I'm not using any global objects by the way.
B
4
Posts: 5
Reputation: 360

Post » Mon Dec 03, 2012 5:59 am

Spritefont was one of Lucid's earlier projects before he learned to code well, and is quite buggy. I reccommend not using it at all. I instead use a sprite with all the letters of the alphabet and set the animation frame for each letter. Coding word wrap was annoying, but it works brilliantly now.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,422

Post » Mon Dec 03, 2012 6:52 am

[QUOTE=Arima]I instead use a sprite with all the letters of the alphabet and set the animation frame for each letter. Coding word wrap was annoying, but it works brilliantly now.[/QUOTE]
Wouldn't that require having to make copies of the same sprite for each of the letters? I've actually had an idea similar to that, but it sounds like it'd be both annoying and inefficient as well considering that there'd be a lot of small sprites in the layout at once (though I'm not sure if SpriteFont is particularly efficient either). I think what would really be ideal is if there was a way I could use one big sprite that contains an image of all the words in the text, and then some sort of way to dynamically modify the image by inserting images of each of the characters inside it. Does such a thing exist? Perhaps in the form of a plugin or one of Construct's built-in functions?
B
4
Posts: 5
Reputation: 360

Post » Mon Dec 03, 2012 9:46 am

[QUOTE=Jimmy52905]Wouldn't that require having to make copies of the same sprite for each of the letters? I've actually had an idea similar to that, but it sounds like it'd be both annoying and inefficient as well considering that there'd be a lot of small sprites in the layout at once (though I'm not sure if SpriteFont is particularly efficient either).[/QUOTE] That's exactly what SpriteFont does too. The only difference is, that the C++-Code may be executed a few milliseconds quicker than events. So, if you don't have any framerate problems using SpriteFont, you also won't have them using clones of a "letter sprite". It's just a bit painful knowing that one has to recreate all the work that lucid already did for us.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Dec 06, 2012 10:25 am

Yeah I'm pretty much ready to put Spritefont to the chopping block too. I wish I could just get normal pixel fonts to display without any subpixel induced sh*ttiness. Anyone got some code sittng around they'd like to share about doing this manually? I pretty much know how I'd go about it, but reinventing the wheel seems less than ideal if someone else has done it better and smarter.
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Thu Dec 06, 2012 3:17 pm

I'm with Arima - take it out! An old CC project of mine used to crash left and right and I finally narrowed it down to the sprite font plugin. There are a few plugin-free bitmap font examples lying around, in fact R0j0hound made one for C2 that you can easily port to CC. Yeah it's not as easy to work with but if it means your game doesn't crash...You can find it hereTokinsom2012-12-06 15:20:08
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 4 guests