GameMaker Keep Aspect Ratio of a Specific Layer when Stretching

P

pytong07

Guest
Is it possible to let some layers to stretch to occupy the whole screen and don't care about the aspect ratio, while stretching other layers and maintain the aspect ratio?
 

TheouAegis

Member
I didn't read the 2.3 manual, but looking at the 2.2 manual, my only idea is to set the layer you do not want scaled up to draw to a surface. , Which hopefully will disable it from drawing to the application surface. if not, I'm not sure where to go with this. anyway, if you can draw the layer to a surface, then in the GUI begin event, I think, draw the surface to the GUI -- I think the application surface gets drawn in the GUI event. However, this may still cause some stretching if the GUI layer is not maximized at a one-to-one ratio. I very well could be wrong, but it's the first thing I would try out if I was trying to do it.
 

Yal

🐧 *penguin noises*
GMC Elder
What are you trying to achieve, more specifically? Layers might not necessarily be the best option to do it.
 

TheouAegis

Member
I assumed it was a bit like parallax, with background layers not stretched. But maybe it's for a UI or HUD, which shouldn't be done with layers, yeah. Then again the principle would be the same as my other idea.
 

Yal

🐧 *penguin noises*
GMC Elder
Yeah, this sounds like an example of what StackOverflow calls the XY Problem: having a problem X, starting a nonsensical solution Y, and then asking about Y when getting stuck even though it might be easier to solve X directly.
 
P

pytong07

Guest
It is an UI. There are UI buttons on the left and right sides of the room on a solid color background. I want this layer to stretch to fill up the screen of the device so that I don't see the black bars on the side.

But there is a sprite in the middle of the screen and I want to keep its aspect ratio without stretching.
 
Last edited by a moderator:

TheouAegis

Member
It wouldn't be automatically scaled, but you can actually fill in those black bars by using the pre-draw or post draw events. Hopefully the code I wrote it up for is in 1.4, but it should easily be applicable to 2+. I was fiddling with all of the draw events one night and basically created the Super Gameboy (sans upscaling).



Prior to GMS, you'd need two views or two surfaces. In Studio, you just use the Predraw event.
 
Top