SpriteFont and Multiple Layouts?

This forum is currently in read-only mode.
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • 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.

  • 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.

  • 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.

  • 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.

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

    Also, check if removing the spritefont plugin fixes it for some reason.

    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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

    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?

  • 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).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.

  • 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.

  • 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 here

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)