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 / Different sizes for different resolutions

Author
Message
wargasmic
17
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 23rd Jul 2012 20:21
I was under the assumption that this was done automatically, but no matter the resolution, the sprites are always the same size. I'm designing my game around the new Ipad resolution (or possible a higher resolution), but It should be compatible for all resolutions. As an example, the new Ipad screen is 2048 pixels wide, so I could sit 32 64 pixel wide sprites side by side to fill the screen but when i run on lower resolution devices I still want to be able to see all 32 sprites one the screen. How is this done? Should I manually set the sprite sizes based on the screen resolution or is there a better way?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 23rd Jul 2012 20:55
If you set a resolution lower than the device supports, it is expanded to fill the space. But not the other way around.

If you use the percentage system, then everything is scaled appropriately.

Cheers,
Ancient Lady
AGK Community Tester
wargasmic
17
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 23rd Jul 2012 21:39 Edited at: 23rd Jul 2012 21:45
Well I'm not sure what I'm doing wrong, but when I set the sprite size it always sets it in pixels.

Here's a code snippet. I hard coded the width and height in the function to test it out. Should be 50% width and auto height. Do I need to enable the percentage system or something?

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 23rd Jul 2012 22:10
I think the display defaults to percentage, unless you use SetVirtualResolution.

Can you show the code that you use to set up the basic display?

Also, the Tier 2 C++ version of SetSpriteSize and SetSpriteOffset commands expect float values for height and width. But, that should only be causing a warning in your compiler. It won't actually hurt anything at execution time.

I know the animation command is using pixels to work with the original image file. I assume that it will scale to fit, but I don't know for certain.

I'm not sure how SetSpriteOffset behaves in the percentage system. I don't know whether it is expecting the display percentage or the pixels.

To be safe, try this for setting the offset:


Cheers,
Ancient Lady
AGK Community Tester
erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 23rd Jul 2012 23:03 Edited at: 24th Jul 2012 01:19
I believe the percentage system does not work in tier2 build 1076' per discussion in this thread

http://forum.thegamecreators.com/?m=forum_view&t=196621&b=41

EDIT: If someone can demonstrate differently please advise as I really would like to get it working!
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 24th Jul 2012 02:46
Here's an example of using the percentage system:



Try changing the device width and height in the Core.cpp. The sprite should always be in the middle and it might change shape.

@ Ancient Lady: Welcome back!

erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 25th Jul 2012 06:28
See attached screenshot using Hodgey's code for AppGameKit 1076 using MS Visual Studio 2010 using 320x, 640x and 1024x in the core.cpp file.

Notice the sprite is not 10%
Notice the sprite is not centered.
Notice the sprite appears to be roughly 10pixels by 10 pixels.
Notice the sprite appears to be at the 50x 50y location rather than at the 50% 50% location.

This is a copy paste of hodgey's code.

I still believe AppGameKit 1076 Tier2 does not work with Virtual Resolutions ; again if anyone using Tier 2 can actually show that it works I'd greatly appreciate it as to my experience so far it does not.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Jul 2012 16:48
I just used a (fixed) VS2010 template and Hodgey's code. I did have to add 'int ' to 'spr = agk::CreateSprite(0);' for it to compile.

The resulting display showed a centered 10% block.

erebusman, you must have done other things to display the size and to set the size. Can you show the exact code you used?

Cheers,
Ancient Lady
AGK Community Tester
erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 25th Jul 2012 17:13
Ancient Lady:

I copied and pasted Hodgey's code from above

and my core.cpp has the below -- with the exception I modified the #define statements for DEVICE_WIDTH and DEVICE_HEIGTH 3 times as mentioned in my post above

This was also a 'fixed' VS2010 Template project that I am using? Maybe we followed different 'fixes'? I really dislike that the templates that ship with 1076 don't work but I know they are trying to do something about that per the post they have up recently so I'll be patient

Thanks for your assistance .. I'm burning a lot of time coding in specific resolutions when I really want to be doing percentage system! Figuring this out is a big deal

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Jul 2012 17:47
I edited the Core.cpp to do different resolutions and they all worked as expected.

Didn't you get the 'undeclared identifier' error for 'spr' on the assignment line? Or do you have that turned off as an error?

Try putting the 'int ' before 'spr = agk::CreateSprite(0);' and see if you still have a problem with the sample code provided by Hodgey.

Cheers,
Ancient Lady
AGK Community Tester
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 26th Jul 2012 03:58
Quote: "Didn't you get the 'undeclared identifier' error for 'spr' on the assignment line? Or do you have that turned off as an error?"

I've got spr there as a global, right above the app::Begin() function.

Here's my core.cpp:


erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 26th Jul 2012 06:25
-- sorry for delayed response was at work

-- per what Hodgey says, he has spr as a global before the app loop begins and I did not get an error

-- Ill copy Hodgey's core.cpp and do a side-by-side compare in notepad++ to see if somethings different and report back in a bit
erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 26th Jul 2012 06:31
other than comments there are 3 differences between hodgey's core.cpp and mine

- I set my device to 1024x768 and he had his at 480x480 (lines 16-17)

- line 559 we set our szTitle to different values -- I named mine after my app , his says template

-- line 587 I have



hodgey has



While I'm new to C++ I think while they are written differently they mean the same thing? And all they pertain to is exiting the loop not the screen resolution anyways?

so I don't think its the core.cpp
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 26th Jul 2012 11:00
The bExitLoop was a result of me tinkering and isn't related to the percentage problem.

This is really strange. We might have to hold tight until the next update.

erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 26th Jul 2012 17:15
Yeah Hodgey you've assisted in trying to figure this out a couple of times and I'm at a loss ... it was a good idea to see if our core.cpp's were different.

I am tempted to install an older version of AppGameKit, then install 1076 on top of it because I never had an older version before and I think most of you did. I wonder if they did not include a file in 1076 but you never noticed because you've had it all along. But something has to be different right?

Then again if that were the case why do I not get errors??

But I'm halfway through my current app and Ive had to design it all with virtual resolution which is very disconcerting ... I'm going to have to do a fair bit of work when I finally get to use percentage system to retro fit the program to work with it. So I'm fairly frustrated ; and the canned version of percentage that came with the examples also does not work on my machine ??
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 26th Jul 2012 17:36
Hodgey, sorry, I missed that line in your code (I should know better than to think that you would post something with an error).

erebusman, can you please show the code from your app based on Hodgey's code that is not working correctly (not the Core.cpp file)?

My tests using his code, doing the same edits to Core.cpp that you did, showed that it all worked just fine.

Cheers,
Ancient Lady
AGK Community Tester
wargasmic
17
Years of Service
User Offline
Joined: 15th Oct 2006
Location: UK
Posted: 26th Jul 2012 21:15
Thanks for the help all. I was setting the virtual resolution, so it was that interfering with the percentage system I guess. It seems OK now, I think!
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 27th Jul 2012 03:02
Quote: "But something has to be different right?"

I would say so. This isn't the first time where I've had the exact same code (seemingly) and the same version of AppGameKit as someone else but get different results.

Try the installation plan and if that doesn't work, I'll upload a 'stripped' interpreter project you can try. That should at least verify that it's not your code that's going wrong.

Quote: "Hodgey, sorry, I missed that line in your code (I should know better than to think that you would post something with an error)."

I have posted faulty code before and I'm always happy to have a second pair of eyes on my code.

erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 27th Jul 2012 06:29
Ok attaching percentage.zip

This is a VS2010 template modified mainly just to have hodgey's code in the template.cpp and I included my core.cpp also

I re-copied the included VS2010 template and put these two files in it and got the same results as my screenshot indicated.


Going to do some AGk reinstalls next will update afterwards.

Attachments

Login to view attachments
erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 27th Jul 2012 07:32
So I did the following

- removed AGK
- reinstalled 1065
- installed 1076 on top of 1065

- retried the percentage system
- still no go


At this point could I get some information about those who *CAN* use the percentage system system settings?

I'm on:

Windows 7 64bit
NVIDIA GeForce GTX 460
DirectX 9.0c and 11 installed
8 GB RAM
.. not sure what else might affect it those make the most sense at the moment?
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 27th Jul 2012 08:04
Have you tried downloading the .zip AppGameKit files?

I'm on
-Windows 7 32bit
- i7-820qm 1.73 ghz
- 4gb ram
- NVidia Geforce GT 230M

Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 14th Aug 2012 15:56
AGK defaults to the percentage system so you only need to call SetDisplayAspect to your chosen aspect ratio (-1 or 0 are special cases that turn off percentage coords).

Personally I prefer working in virtual coordinates so from the original post doing

Will allow 32 sprites of 64 pixels each on all devices no matter what resolution they really support. AppGameKit will scale this fake resolution over the top of the device.

Login to post a reply

Server time is: 2024-05-02 10:48:10
Your offset time is: 2024-05-02 10:48:10