Reuse the font sprite graphics on more than one text

0 favourites
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Hi.

    Maybe a stupid question.

    But I have a few texts shown on the layout. Each text use the same spritefont.

    But I have to attache the same spritefont.png to each sprite, and I can see on the status bare that the size of the game increases for each sprite I add the same spritefont to.

    Is there a way where you can reuse the same spritefont.png file for more than one spritefont sprite? To save ressources and keep the game as small as possible, but also to make it easier if I want to change the sprite font to a different font, so I do not have to alter each sprite manually.

  • Use the same spritefont and make a new instance of it. I haven't done so myself but I need to do so. I guess for static text it will work.. Of course someone here will chip in with better solution.. But maybe identify by variable?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you should just use one Spritefont object if they are all the same font. then if you need the font to change at runtime just assign a variable like helena said. It works this is how i change font in all my games

    Edit: beaten

  • If I only have one spritefont.

    How can I place 4 different texts on 4 different positions in the layout, without having 4 instances?

  • hgr you can't. 4 different texts will always work out to be 4 different instances unless you wanna do some crazy and extensive math to fit all 4 texts in instance, which is a bad idea.

    So yeah, just go with the other suggestions. You will need to create 4 different instances.

  • Maybe instances has been mixed up with objects?

    instance = copies of one object. (= only one sprite sheet is used)

  • One SpriteFont with instance variable.

    As was stated, you will have to have multiple instances of your single SriteFont object. The number of instances would vary depending on needs.

    Just a quick example:

    4 instances of said SpriteFont with different variable values for each instance.

    SpriteFont | is on screen

    Variable = 1 | set text to "this is instance 1"

    Variable = 2 | set text to "this is instance 2"

    Variable = 3 | set text to "this is instance 3"

    Variable = 4 | set text to "this is instance 4"

  • I think Helena nails the problem. Sounds like the OP is confusing instance and Object. As once you create the Object and set the Sprite to the right font. your only drag and Drop or Ctrl+c/v for new instances of that object.

  • And if you think it is too confusing to update and keep track of the variables, an alternative is to make the sprite font png just 0-9 for the score numbers. It at least will make the png file a tiny bit smaller.

    Then you can use individual objects with only 0-9 for the number keeping and then a object with full character set for making instances with texts. (for dialog, info messages)

  • Ok thanks.

    So just to be crystal clear.

    If I copy an instance of a sprite font object. And I change the graphics on either one of them, it will update the graphics on all instances it has been copied from?

  • That's right. Just try it and see

  • Ok got it.

    Thanks for your help.

    It would be nice if you could see an the instances in your inspector and give them a name.

    What tends to confuse me is that the Name property is the property of the object, not the instance.

    It would be nice if you could name instances and have them available in your events sheets as if they were instance variables ( in ordinary programming )

    This is whats confusing me.

    Now you have to pick by uid, which you cant trust because they change, so you have to save these values in an array or dictionary, and it just makes the code hard to read I think.

    So if any from the scirra team is reading this... Instance names, would be nice.

  • Ok got it.

    Thanks for your help.

    It would be nice if you could see an the instances in your inspector and give them a name.

    What tends to confuse me is that the Name property is the property of the object, not the instance.

    It would be nice if you could name instances and have them available in your events sheets as if they were instance variables ( in ordinary programming )

    This is whats confusing me.

    Now you have to pick by uid, which you cant trust because they change, so you have to save these values in an array or dictionary, and it just makes the code hard to read I think.

    So if any from the scirra team is reading this... Instance names, would be nice.

    What name would you give to your instances? Remember instances can be dynamic, not just placed at design time. You can always add an instance variable yourself to identify it in the inspector (where you already can see the instances, numbered by IID). If you're still thinking as per traditional programming, you still need to do the 'paradigm shift'

    I do agree it should be 'Type' not 'Name'

  • Simple...

    When I edit the code in the evnet sheet. It would be so nice if I could select the instances by name. Especially when you access instance variables..

    InstanceName.instancevariable

    Instead of now,

    ObjectName.InstanceVariable.

    If your instance is on the layout. It is declared as available in the game for your events. Sure it makes no sense if you spawn instances in events. But whey they are placed on the layout. It would be so nice If I could access them by name instead of IID (or UID)

    And yes it is traditional programming, in Visual Stucio / xCode etc. And not drag and drop in Construct 2.

  • Simple...

    When I edit the code in the evnet sheet. It would be so nice if I could select the instances by name. Especially when you access instance variables..

    InstanceName.instancevariable

    Instead of now,

    ObjectName.InstanceVariable.

    If your instance is on the layout. It is declared as available in the game for your events. Sure it makes no sense if you spawn instances in events. But whey they are placed on the layout. It would be so nice If I could access them by name instead of IID (or UID)

    And yes it is traditional programming, in Visual Stucio / xCode etc. And not drag and drop in Construct 2.

    Fair enough. Somehow it becomes natural pretty quickly to do things the Construct way Usually when I have fixed objects in a layout they will have an ID value, and sometimes I do use that in a similar way. You could have a dummy Text instance variable with values like "top", "bottom", "this one" or whatever to identify them if you wanted . Or create a really simple Behaviour with a single property 'Instance name'.

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