Changing the “Text” size, even though a previous scale has been set.

Not favoritedFavorited Favorited 0 favourites
  • 8 posts
From the Asset Store
A versatile and wide-ranging selection of large to medium-sized creature sounds.
  • I'm creating a versatile module for the GUI (so I can quickly create buttons and other GUI elements for future projects).

    const childInstanceSizeList = {}
     for(const instanceObject of childInstanceList){
     childInstanceSizeList[instanceObject] = [];
     if(instanceObject.instVars && instanceObject.instVars.isText){
     childInstanceSizeList[instanceObject].push({x: instanceObject.width / instanceObject.textWidth, y: instanceObject.height / instanceObject.textHeight})
     } else { 
     childInstanceSizeList[instanceObject].push({x: instanceObject.width / instanceObject.imageWidth, y: instanceObject.height / instanceObject.imageHeight})
     }
    
    //next
    
    for(const instanceObject of childInstanceList){
     const originalScale = childInstanceSizeList[instanceObject][0];
     instanceObject.behaviors.Tween.startTween("scale", [originalScale.x + 0.2, originalScale.y + 0.2], 0.1, "in-out-sine")
     }
    
    for(const instanceObject of childInstanceList){
     const originalScale = childInstanceSizeList[instanceObject][0];
     instanceObject.behaviors.Tween.startTween("scale", [originalScale.x, originalScale.y], 0.1, "in-out-sine")
     if(instanceObject.instVars && instanceObject.instVars.isText){
     console.log("Original scale:")
     console.log(instanceObject.height / instanceObject.textHeight)
     }
     }
    
    

    For some reason, every time I press the button, the scale gets smaller.

    Tagged:

  • My guess is that at some point you're accidentally overwriting the stored scale. It's impossible to tell from the code you posted though where/when it runs. Ideally you could upload your c3p file to a google drive or somewhere and post it here. You can strip out anything you don't want/need to show before.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • drive.google.com/file/d/1pe18O5YcZy5hOwnLuo8oUZSI-ejh0Et1/view

    Thank you so much for the advice. I think I really should have sent the file right away, since there’s nothing in it worth hiding.

  • It says I don't have access to the file, you have to make it public

  • drive.google.com/file/d/1pe18O5YcZy5hOwnLuo8oUZSI-ejh0Et1/view

    Sorry, I forgot to make the file available. Does the link work now?

  • Yeah it works now.

    As for the project, honestly I can't tell what's going wrong.

    My suggestion would be to just make use of hierarchies though, see construct.net/en/make-games/manuals/construct-3/interface/layout-view That should cut down on some of the complexities you have going on.

    If you have your button and add the text object as a child (or as many other objects as you wish) all you need to do is tween the button, and all the children will scale accordingly. This also circumvents the issue that tweening the text object scale doesn't scale the font size.

  • Thanks for looking at my code. I think you're right, and I really should look into using hierarchies (to be honest, I hadn't paid much attention to them before).

  • Oh you should absolutely pay attention to them and templates too. These two features are insanely useful. I could never go back to not having them.

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