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 / DrawSprite() size and position problem

Author
Message
Jambo B
14
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 21st Feb 2015 16:17
Hello all
I’m trying to draw a box onto an image by pasting sprites of various shapes. I’m using DrawSprite() to do the rendering onto a back image.

I’m new to DrawSprite(), and I’m obviously missing something here, because the positions and sizes of the pasted sprite change depending on whether the app is running in fullscreen or windowed:

WINDOWED


FULLSCREEN


Would anyone mind having a look and seeing where I’m going wrong? Here's the code, the media is attached.



Thanks for any advice,

James

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Feb 2015 16:27
Ok, not tested this but it looks like because you are using SetVirtualResolution(GetVirtualWidth(),GetVirtualHeight()) in fullscreen these values will be different. Just take this line out and it should (I hope) be fine...


Using AppGameKit V2 Tier 1
Jambo B
14
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 21st Feb 2015 18:08 Edited at: 21st Feb 2015 18:09
Thanks Baxslash. I tried that, unfortunately this doesn't solve the problem. The pasted sprites are then too small.

James
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 21st Feb 2015 18:58
You don't call CreateRenderImage anywhere?

I had no idea you could just render to any image without using the above command, weird

Also, are you hoping that SetVirtualResolution() is going to have an effect on the render image? That also seems strange to me. Can the resolution of the render target be virtual?

I would be doing something like this:


Then create a sprite for your box(imgRender) and place it where you want it. I would not be including the backdrop as part of the box, seems to complicate things and not be as flexible imo.

This still may not solve your problem but I think it simplifies what you are doing a little which may help.

Jambo B
14
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 21st Feb 2015 19:55 Edited at: 21st Feb 2015 20:05
Hi Matty H

Thanks for the reply. I tried using CreateRenderImage, but couldn't get transparency to work properly in full screen:

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

The problem was that there were visible artifacts around the outside of the image. The problem was solved in the above post, but when fullscreened, I found that the problem returned.

I think it's definitely something to do with resolution.

James
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 24th Feb 2015 14:01 Edited at: 24th Feb 2015 14:02
I re-sized your background image to 1024x768 (you could do this in code to dynamically re-size the background image to the device width/height if you needed to).

I also removed the line:


Was not sure of the purpose of that line when you had already set the virtual resolution to 1024x768.

Anyway, the results are:

Fullscreen:


V2 T1 (Mostly)
Uzmadesign

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 24th Feb 2015 14:02 Edited at: 24th Feb 2015 14:36
2nd image (Windowed Mode):



(Note: The moving sprite is only further away from the block of 'pasted' sprites because it was running for longer when I hit print-screen)

V2 T1 (Mostly)
Uzmadesign

Attachments

Login to view attachments
Jambo B
14
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 24th Feb 2015 20:04
Thanks, CJB

Wondered if there was any way to accomplish this without resizing the background to 1024x768. I was hoping that

SetVirtualResolution(GetVirtualWidth(),GetVirtualHeight())

would cause the surface I'm pasting the sprite onto to be the same rez as the app.

Thanks to anyone with any thoughts about this!

James

Login to post a reply

Server time is: 2024-05-18 18:05:17
Your offset time is: 2024-05-18 18:05:17