Resizing Sprite based on Image Dimension and Window Sizes

  • Hey everyone. Hope you are having a good day.

    I have been trying to find a way to resize a sprite whenever I call loading an image from a URL. Been having a hard time grasping this concept for a good while.

    I want to load the image into the sprite, resize it to fit a mobile phone screen size. I know how to resize to the screen, but it gets all skewed and the actual image dimensions get messed up and the image doesn't look right. So how could I approach resize the image based on its dimensions, but still be able to fit the screen size(mobile)?

    I tried using the Sprite.ImageHeight and ImageWidth checks, I think I am on the right path, but not total for sure.

    This would have been an easy fix by hard coding the right size, but the images will be dynamic via user uploads. So I have to think of a dynamic scaling system.

    Thank you for your time!

    Edit: I have gotten close to getting this working however this aspect ratio just does not meet my requirements.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Anyone know of a good way?

  • my stupid way

  • fongka2

    Thanks for the example, but that does not necessarily solve my problem. My image assets are never the same dimensions, they will be dynamic so I can not give exact hard-coded math formula like you have for your objects as they are not dynamic.

    A user will be uploading images on their own, so height and width dimensions will always vary.

  • I am also surprised there isn't a built in function to C2 for something like this...

  • I think I have a workable solution, it does scale the images to what appears to be the correct aspect ratio... it just scales the images waaaaaaayyyyyyyyyyyyyy too small. I think I am close though.

  • Still having issues can't seem to get anything to work

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