Biscotto's Recent Forum Activity

  • I'm learning to use Construct 3, and using Sprite Fonts for the first time to create custom fonts, I had a doubt regarding the optimization of these objects (I would like to use them in the best possible way avoiding unnecessary actions).

    I've noticed that at the creation of each SpriteFont object, it is necessary to load an associated sprite, and insert all the necessary data so that Construct can obtain the font from the loaded font grid.

    If I want to create multiple text objects with different font properties (e.g. color, spacing, size etc.), I have to load the same sprite multiple times, and I think Construct has to recalculate the font from the loaded sprite each time.

    To avoid this "waste" of memory, I thought of creating a single object, and using events to create a new instance and add a different text each time. In this way I could use a single SpriteFont object, but I don't know if this is a good solution since in the various tutorials I've seen, a different text object is used for each text in the game.

    That said, I would like to ask you more experts what is the best method to work with SpriteFonts.

    For example, if I have to create several SpriteFont objects, is it advisable to load font sprites containing only the necessary characters in order to "lighten" to Construct the work necessary to build the font? Or are there no problems in selecting and assigning the usual sprite containing all the characters?

    Do you have advices or indications to give me to use in the best way the SpriteFont?

    Thanks! :)

  • Hi,

    if you want to do a quick check there is the "Contains value" event that loops the entire array for you and returns true or false if the value you have indicated is contained in the array.

    Otherwise you can start a "For each element" event, and insert a check sub-event to check if the value you are looking for is present at the "loopindex" position. If yes, then you can decide to delete the value present at that position.

    I hope I've been helpful!

  • Maybe with this information you can solve your problem. Adjust the "distance()" function according to the data you have. ;)

    TileToPositionX(x)

    TileToPositionY(y)

    Convert a tile position to layout co-ordinates. For example, this can be used to position a Sprite object on top of a given tile.

    distance(x1, y1, x2, y2) Calculate distance between two points

    distance(Tilemap.TileToPositionX(tileX), Tilemap.TileToPositionY(tileY), You.X, You.Y)
    
  • Thank you for your response Ashley.

    So if I understand correctly the only way to copy an array object into an array is this?

    let solutionObj = runtime.objects.Solution.getFirstInstance()
    
    let tempArray = []
    
    for (let i=0; i < solutionObj.width; i++) {
    	tempArray.push(solutionObj.getAt(i, 0))
    }

    Or are there better ways to make a copy?

    Checking on the page you linked me to, it doesn't look like I can directly reference the array and copy it with a single string (example: let tempArray= [...solutionObj]), but I need to reference each cell at a time. Right?

  • I'll preface this by saying that I'm a neophyte to Construct and I'm just now getting into JS insertion within the event sheet.

    Within my game I have an Array object called "Solution". In my script I would like to make a copy of said array.

    To understand it I would like to do this (written in normal JS):

    let solution = [1, 2]
    let solutionCopy = [...solution]
    

    Giving a reading to the manual I tried to write some code, but it is reported in red, and therefore wrong:

    let solutionCopy = [...runtime.objects.Solution]
    

    Also subsequently, I can't access the length of an Array object, via JS code:

    for(let i = 0; i < runtime.objects.TempRow.lenght; i += 0) {
    

    I think I'm still unclear on how to properly access the data of an Array object via JS. Can anyone help me and give me some explanation?

    Thanks

  • The letters need to be left-justified, not centered.

    That's right.

    Unfortunately, I had missed this part of the manual, and was wrong about leaving the characters centered to their own cell.

    Below is part of the text from the manual, so that it may help in case someone has the same problem as me:

    Individual characters can be displayed with a different width using Spacing data or the Set character width action. In this case, the character should be drawn left-aligned within its cell.

  • I've created my own custom font, but I'm having trouble setting the spacing for each character.

    This is my current situation:

    Checking the various sprite font properties in the manual, I found the "Spacing data" property that I thought was right up my alley.

    So I set the "Spacing data" field of my project by inserting a JSON that would indicate the width values of each character.

    Below I leave you the JSON that I wrote (upper and lower case letters are represented by the same character and therefore have the same width):

    [[20,"Ii"],[32,"EeFfLl"],[36,"AaCcDdHhJjKkNnOoPpQqRrSsTtUuVvXxYyZz"],[38,"BbGg"],[52,"MmWw"]]

    The problem is that as you can see from the first image I posted, the whole thing doesn't seem to work properly. The problem is most visible with the letter "i".

    I double-checked the pixel width of each letter I entered in the JSON, and I'm 100% sure I entered them correctly.

    The sprite I used for the font has cells of size 52x66 (as indicated in the font sprite properties), and all the letters are centered within their own cell. Also, the "Character set" property is set with the correct sequence of characters.

    Can anyone tell me where I'm going wrong?

    Tagged:

  • Does anyone have any tips to protect my game saves (mainly on mobile, but also on browser) from possible modifications and cheats?

    I'd like to find a method that prevents a player, for example, from adding coins by simply editing the save.

    Thanks

  • Thank you for your responses! :)

  • I've recently started using Construct 3, and I've noticed that the handling of arrays is a bit different than in other programming languages (at least as far as the event sheet is concerned).

    I would need to insert inside a cell of an array, another array, and then remove it and get the array just removed.

    Using normal JS I would like to recreate this code:

    	myArray = []
    	myArray.push([a, b])
    	var [a,b] = myArray.pop()
    

    Unfortunately, I noticed that Construct only allows you to work on one axis at a time (x or y), and so I can't populate the array with the two new values.

    Same problem for when I want to pop the inserted array.

    Can someone explain me how it works and how I should act in these two cases?

    Tagged:

  • Perfect, thank you so much for the clarification.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you tried creating your own list of events?

    If you already have a base to work from, we'll find it much easier to help you by figuring out where you're going wrong and correcting the wrong events together.

    I think even a simple screen of your event sheet can be of great help. :)

Biscotto's avatar

Biscotto

Member since 11 Aug, 2021

Twitter
Biscotto has 1 followers

Trophy Case

  • 3-Year Club
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Quick Draw First 5 people to up-vote a new Construct 3 release
  • Email Verified

Progress

7/44
How to earn trophies