TrickyWidget's Forum Posts

  • I'm trying to convert from Texts to Sprite Fonts for performance reasons, and I'm a bit stuck on the differences in how they behave.

    I have a card Sprite, which had seven Texts associated with it (name, stats, etc). I had all of these in a container so that I could easily manage them as a unit.

    However, when using a Sprite Font, the entire font texture appears to be loaded for every individual object. So if I have seven different Sprite Fonts in the container, that's seven copies of the font texture taking up resources. Which is no good.

    The seemingly obvious answer would be to use multiple instances of a single Sprite Font object. But I can't figure out how to make that work properly with containers. If I only have the one Sprite Font object in the container, how will it know which seven instances in particular to select/destroy in association with the rest of the container?

    Thanks!

  • I've got a relatively simple game and I'm trying to optimize its performance on mobile.

    I'm getting pretty decent FPS on both my Android devices. About 50 at rest, down to 30 or so during heavy animation. I can live with that just fine.

    The big problem I'm having is that everything is sluggish in responding to input. I tap a sprite and there's a noticeable lag before it does anything. Sometimes a very long lag. Fairly often, nothing ever happens at all and I have to tap again, possibly several times. This I can't live with.

    I've read all the performance guides and tweaked all the things they say to tweak. WebGL is running. Transparency is trimmed. Sampling is point. Etc, etc.

    The two devices I have to test on are a Samsung Galaxy S III phone (top of the line two years ago) and a LePan II tablet (middle of the road two years ago). I'm using the recommended XDK/Crosswalk method for building my APKs. I'm making heavy use of the LiteTween add-on behavior.

    Unfortunately, due to licensing restrictions with my art, I can't actually post a capx. But debug says I've got 131 objects occupying 19.3 megs of memory. The phone idles around 20% CPU and peaks about 65% (according to cpuutilisation). The tablet is about 10% and 70%.

    I'm primarily aimed at deploying on Android, so this is a really central issue for me. Does anyone have any suggestions?

    Any help would be greatly appreciated. Thanks!

  • I worked out a fairly simple routine for sorting a two-dimensional array by multiple columns (first by D, then by A, etc). It leverages Array.Sort to do the heavy lifting, so it's just a matter of moving the data around to the right places. I couldn't find any examples of this, so I thought I'd share it in case anybody else is searching.

    It looks something like this:

    [attachment=1:1oxs8f6h][/attachment:1oxs8f6h]

    Some caveats:

      Arrange the Sort_Column() calls in reverse order of priority. Array.Sort reverses previous ordering, so you might have to change your "Ascending" or "Descending" to the opposite of what you'd expect, depending on the sorting that happens after that call. Be sure to include the "Ascending" parameter even though it's the default. If you don't, a "Descending" entry from a previous call could be lingering in the Function object which would give the wrong direction.

    I hope this is useful! If you have any questions or improvements, just let me know.

    Example attached!

  • Gah! After all that, it turns out the Nickname addons only work when you already have at least one instance of the tagged objects on the layout. Which isn't at all workable for my scenario. Alas.

    So if anyone else has any thoughts on how to store an object reference in an instance variable, I'd love to hear them!

    Until then, I'm back to my ever-growing lookup table.

  • "Action:Create instance into family" is another way to create instance, and it will put the created instance into SOL of this family.

    Thank you for the feedback!

    I just realized that I somehow overlooked the condition in the plugin that does exactly what I need:

    [attachment=0:1vhkb3lg][/attachment:1vhkb3lg]

    Thanks again! Your addons are going to be a real boon to my projects.

  • Whats wrong with this then ?

    The trouble was that Sprite could actually be a great many different objects, so I couldn't reference them collectively that way. However, your proposal got me looking over things again, and I realized that I'd been a total idiot! The nickname plugin offers exactly the condition that I needed:

    [attachment=1:1t4xufkl][/attachment:1t4xufkl]

    Voila! All I needed was to have all possible sprites in a family (which they already were) and then use the nickname picker (that I somehow overlooked like five times yesterday) to select it.

    Thanks so much for your help! This will save me a great deal of effort.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Pick it by largest IID maybe?

    Unfortunately, I don't have any way of knowing what object the instance was created from. So I wouldn't know what to search for an IID. At the time of creation, this "nickname" is all I have.

  • Try this, not sure if its what you want though.

    Thank you for the effort.

    Here's what I'm trying to do:

    [attachment=1:2mq55056][/attachment:2mq55056]

    This creates a new instance of Sprite which was nicknamed "Monster", which is exactly what I wanted. However, now that I've created it, I need a reference to it so that I can work with it. So I need the UID or some other way of picking it.

    Example attached.

    Thanks again!

  • Maybe this could help..

    Thanks for the tip!

    That looks like it might be just what I need. I can create an instance from its nickname. However, so far I can't figure out how to get the UID of the instance that was created. Do you happen to know how to do that?

  • Thanks for creating these great addons!

    I have a question. Is it possible to get the UID of the instance created with Action:Nickname-Create instance?

    [attachment=0:24q5egmx][/attachment:24q5egmx]

    Thanks!

  • I have a family of sprites. I need to be able to create a particular one as indicated by the instance variable of another object. But I can't find any way to directly store an object reference in an instance variable. The best I've come up with so far is this:

    [attachment=0:2cu15kz1][/attachment:2cu15kz1]

    That works just fine, but I'm going to have over a hundred sprites in the family. Which means this sort of manual look-up table is going to get really unwieldy.

    Does anyone have any thoughts about a better way to do this?

    Thanks!

  • Well, I made a sort-of solution. I created an event group that repositions the sub-sprite to the main sprite's image point every tick. Then I turn it on at the beginning of the tween and off at the end of the tween. It's a total hack, but it works.

    Example attached.

    If anybody has any thoughts about a more elegant solution, I'd love to hear it!

  • I'm trying to tween the scale of a compound sprite and it's giving me trouble.

    I have the sub-sprites pinned to image points on the main sprite, and for the most part it works fine. But when I change the scale of all the various parts, they also change location relative to one another. I can re-orient them after the fact, except that I'm tweening the change of scale. Which means that all the parts smoothly scale into the wrong places and then suddenly leap to the right places at the end.

    I've tried giving each part its own tween, but I'm also rotating the main sprite so trying to keep up with the destinations of all the various parts is nigh impossible.

    Does anyone have any thoughts on how to work around this?

    A simple illustration of the problem using LiteTween is attached.

    Thanks!

    [attachment=1:qjps06qs][/attachment:qjps06qs]

  • Ok, this one should have fixed it, the scale tween vs mirror and flip.

    Wonderful, thank you!

    Could you explain the bug about 'Moving' with LiteTween undoing flip/mirror? The code on the position tween have nothing to do with Height or Width, so it shouldn't even affect anything about scale.

    Ah, my mistake! Looking back over my code, the moving I was thinking of also involved scaling. So it seems that was the whole thing. Sorry for the trouble.

    Thanks again for your great work!

  • You can duplicate the image and change the image point in the second frame.

    True, and that's what I'm doing for now. But I was hoping to not have to pack in extra images just to change a reference point.