Resizing Sprite based on Image Dimension and Window Sizes

Get help using Construct 2

Post » Sat May 17, 2014 3:12 am

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.
Last edited by GameThirsty on Wed May 21, 2014 2:04 am, edited 1 time in total.
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Wed May 21, 2014 2:00 am

Anyone know of a good way?
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Wed May 21, 2014 5:53 am

my stupid way
You do not have the required permissions to view the files attached to this post.
B
17
S
7
Posts: 360
Reputation: 2,202

Post » Wed May 21, 2014 10:57 pm

@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.
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Wed May 21, 2014 11:39 pm

I am also surprised there isn't a built in function to C2 for something like this...
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Thu May 22, 2014 1:30 am

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.


Image
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Fri May 23, 2014 4:36 pm

Still having issues can't seem to get anything to work
B
17
S
6
Posts: 348
Reputation: 2,608


Return to How do I....?

Who is online

Users browsing this forum: Manubis, TheSupreme and 11 guests