This code is only used for Percentage based system in Teir 2.
I put code for Tier 1 but I work solely in Tier 2.
Here is the little formula I used to get buttons to appear in the same location
in relation to the newly resized image after you have set the sprite size using the SetSpriteSize() function.
I think this is helpful when you have sprite windows of different sizes and you want them to have their own buttons and such.
This will get the buttons to remain in the exact position across different resolutions.
Tier 2:
//the only value you have to change is the offset value
//once you figure out where you want your sprite
float offset=6.50;
float yposPic = 30.00f; //where the pic will be place on the screen
timesPic = new CSpriteImage("pics/tiles/pic1.jpg",0.00f,0.00f);
//find out picture height aspect ratio
HeightofPic = agk::GetSpriteHeight(timesPic->GetSprite());
HeightofPic = (HeightofPic - (HeightofPic/offset));
timesPic->SetPositionOfSprite(-100.00f,(HeightofPic +yposPic) );
timesPic->SetSizeOfSprite(100.00f,-1.00f);
//new spi
Tier 1:
rem Portrait App
SetDisplayAspect( (768/1024) )
global offset as float = 50.00 //I don't know why the offset has to be so much higher than in Tier 2...
global HeightofPic as float=0.0
backdrop = CreateSprite ( LoadImage ( "timesup1.png" ) )
btn = CreateSprite ( LoadImage ( "next.png" ) )
SetSpritePosition(backdrop,12.50,10)
SetSpriteSize(backdrop, 80, -1)
setspritedepth(backdrop, 11)
SetSpritePosition(btn, 700,600)
SetSpriteSize(btn, 15, -1.00)
setspritedepth(btn, 1)
//find out picture height aspect ratio
HeightofPic = GetSpriteHeight(backdrop)
HeightofPic = (HeightofPic + (HeightofPic/offset)) //...and I don't understand why I have to add here, when in Tier 2 I subtract. Wierd
SetSpritePosition(btn, 45,HeightofPic)
Thanks to Naphier for pointing out the GetSpriteHeight function to me. That got me moving forward.
Joeisms
KG2Entertainment.com