Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Scaling pictures to fit in screen

Author
Message
Corno_1
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 8th Oct 2015 12:47 Edited at: 8th Oct 2015 12:49
Hi,

I bought AppGameKit 2 through a steam sale and I really liked it. I programmend some apps for me, but now I have a problem:

I want that the pictures fit in the device screen, but if the picture is wider than heigh it scales the picture to 1366/454. The display screen is 1366/768.
The methode also center it

Here is the code:


Any help is aprreciated

Corno_1
PredicateC - FPSC to GameGuru FPE converter
https://forum.game-guru.com/thread/211068
Corno_1
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 8th Oct 2015 13:35
Ok, solution found!


Sometimes you must rethink your hole concept to find your mistake
PredicateC - FPSC to GameGuru FPE converter
https://forum.game-guru.com/thread/211068
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 8th Oct 2015 13:39
All you must do is set the sprite size the display width and height.

DeviceWidth# = GetDeviceWidth()
DeviceHeight# = GetDeviceHeight()

SetSpriteSize(Sprite,DeviceWidth#,DeviceHeight#)




SetSpritePosition(image,GetDeviceWidth()/2-(GetSpriteWidth(image)/2),GetDeviceHeight()/2-(GetSpriteHeight(image)/2)) <-----You do not need this.
You do not need this because the positioning does not start at the middle of your sprite which you would suspect.
The positioning starts from the Top-Left corner of your sprite. So if you size your sprite to the screen specs it will fill the screen with out having to be positioned.

If you wish to fix it to the screen, if you are using it as a background.
FixSpriteToScreen(Sprite,1)


Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Oct 2015 15:54
Also, if it is a full-screen background image, probably worth taking a look at SetSpriteTransparency too. (Turn off transparancy on background image to improve preformance).
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Oct 2015 21:08 Edited at: 8th Oct 2015 21:09
better use
GetVirtualWidth ()
GetVirtualHeight ()
at SetSpriteSize( iSpriteIndex, width, height ) u can set width or height to -1 for 1:1 pixel aspect.
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Corno_1
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 11th Oct 2015 16:51
Maybe there is a missunderstanding. The picture should fit into the screen without any changes at the shape. If I use

DeviceWidth# = GetDeviceWidth()
DeviceHeight# = GetDeviceHeight()
SetSpriteSize(Sprite,DeviceWidth#,DeviceHeight#)

the picture become stretched. This should not be. But thanks for all your answers.
PredicateC - FPSC to GameGuru FPE converter
https://forum.game-guru.com/thread/211068
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Oct 2015 18:05 Edited at: 11th Oct 2015 18:08
if u use a 100:100 aspect ratio because (virtual) resolution of 100x100 and a 16:9 screen, sure it will be stretched.
then u can use
DeviceWidth# = GetDeviceWidth()
DeviceHeight# = GetDeviceHeight()
SetSpriteSize(Sprite,-1,DeviceHeight#)
or
SetSpriteSize(Sprite,DeviceWidth#,-1)
if u not want borders the image should be a square.
u can position it in the middle screen SetSpritePositionByOffset ( iSpriteIndex, GetDeviceWidth()/2.0, GetDeviceHeight()/2.0)

also look for SetScissor( 0,0,0,0) and
GetScreenBoundsBottom ()
GetScreenBoundsLeft ()
GetScreenBoundsRight ()
GetScreenBoundsTop ()

AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-09-29 05:27:53
Your offset time is: 2024-09-29 05:27:53