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 / Scissor Problem for join two Image

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jan 2015 13:18
Hi.

I think maximum image size for use is (1024 x 1024). now my screen size is (1280 x 800) and can't use it Directly. so I've divided it into two parts.

in window two images are join together, but when load it in android image not join together.

I attached my Project. Please tell me where is the Problem.

Thanks.

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th Jan 2015 14:03
You need to set your background images size and position for them to appear in the right place. You say this worked in Windows!???

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jan 2015 14:09
Yes, Work in Windows.

this is a Picture form Android.

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th Jan 2015 14:12 Edited at: 9th Jan 2015 14:14
Try this as your "CreateSprites()" function:


edit:
Probably worth setting your virtual resolution before loading images & sprites etc. too.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jan 2015 14:28
this function work but make exist black border.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th Jan 2015 14:39
To remove the black bars, you can either change the ratio to fit the physical screen, or make your images a bit wider and position them to draw outside you virtual res (you'll need to SetScissor(0,0,0,0) in this case).

By using the forum SEARCH facility, I also found the following from Ravey to set the ratio:



Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jan 2015 14:54 Edited at: 9th Jan 2015 16:15
this function make zoom in windows and android.




I used this function that work very well before use half image:



I test several state for fix this Problem but no change anything.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jan 2015 17:09
anyone have solution?
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th Jan 2015 17:29
It works fine in Windows & Android. What value did you give it as height?

Here: I've moved it all into the main (as you already had the ratio calculating thing in your #include file), but it works fine:





Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Jan 2015 17:57
Quote: "anyone have solution?"


Yes.
Take up stamp collecting instead
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jan 2015 18:17 Edited at: 9th Jan 2015 18:20
Quote: "Yes.
Take up stamp collecting instead"


You're a man of wit.

Thanks CJB.

it show in my phone like this:

The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 10th Jan 2015 10:39
The reason you get a black border is because your sprites are too small for that resolution or you have placed them incorrectly.



You have probably got your resolution wrong when you made the images

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2015 11:09
I used this code :

Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 10th Jan 2015 12:08 Edited at: 10th Jan 2015 12:09
Zog2 is right, but you keep on not understanding it...

Your code, sets a dynamic unknown resolution to cover the device's screen, to avoid border, but you still need to make sure the images cover the whole screen.

You do not know how wide the screen will be, if you use this code, so you must find a way to compensate.

Use a set resolution, and forget the black borders, or make the pictures oversize so that they get clipped on low resolution devices, and cover all the screen at high resolution devices, but then you need to make sure no vital information will be missing on the devices with lower resolution.

To make a game that uses dynamic mobiles resolutions, require a programming genius to handle... I have not even considered doing it, and I have programmed for 20+ years...

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Jan 2015 13:33
I normally allow an area around the edge of the screen as a "buffer" area which never contains anything vital. I position sprites that need to fill the screen in the centre of the screen and either set the size of the sprite to fit the height or width of the device (whichever is smallest). The other way is to stretch to fit the screen which can work well with patterns but not so well with a scene like this.

I have an image somewhere that I use as a reference for "standard" screen resolutions which I will post if/when I find it but I normally allow a 4:3 area centrally that is always "safe" for the majority of the menu/play area.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2015 14:49 Edited at: 10th Jan 2015 14:59
according to All the talk about scissor I think Indirect understood I had three choices:

1- leave AGK
2- Never make mobile games with AGK
3- make mobile games even commercial with black border

right?

anyone made a commercial game with AppGameKit with black border?

Black border good not show in small devices but at lager devices like tablet show Himself very well.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 10th Jan 2015 17:28
Quote: "I normally allow an area around the edge of the screen as a "buffer" area which never contains anything vital."


That doesn't mean leave black borders. You can still draw sprites in the "Buffer zone" to completely fill the display, just not sprites that are important for the functionality of your game. You get me?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Jan 2015 17:45 Edited at: 10th Jan 2015 18:14
You mis-understand, here is an image to explain. The red shape is a screen resolution, the image is a background image / menu layout:



If the image aspect ratio does not match the screen then I allow the image to go past the edge of the screen.

TRY THESE EDITS TO YOUR ORIGINAL CODE you can use "stretch" or "fill" modes with your background sprites:
main.agc


globalfunction.agc


Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2015 20:50
Thanks baxslash for help and code.

but there is Problem at this 2 method.

when used fill, my image zoonIn like below picture.



and when used stretch, my image show like below picture.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Jan 2015 21:05 Edited at: 10th Jan 2015 21:09
Did you use only the code exactly as I posted it or did you change anything?

The top image is correct, it is filling the space vertically and going over the edges. The bottom image is stretching to fill a resolution which is the same height and width...

EDIT: Nevermind, I screwed it up. Fixing now...

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2015 21:13
Quote: "Did you use only the code exactly as I posted it or did you change anything?"


I directly copy and paste your code, then export it to android.

fill image is very ZoomIn and only show center of Picture.I think it good and full show only at height relosution.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2015 21:46 Edited at: 10th Jan 2015 21:49
Thanks you very much baxslash As always a great help to me.

I fix it.



can you explain more about this line?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Jan 2015 21:52
This version works 100% for virtual and percentage. Fully tested it this time
main.agc


globalfunction.agc


Quote: "can you explain more about this line?"

That line positions the sprite in X by the centre of the display minus half the size of the sprite and in Y by the centre of the display minus half the height of the sprite.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Jan 2015 05:25
thanks baxslash, this code better work.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 12th Jan 2015 15:00 Edited at: 12th Jan 2015 15:02
baxslash i find a Problem in above codes.I show it with Picture.

this is two picture from my game at windows:





and this is two picture from my game at Android:





you can see there is 2 problem.

1- I Created a Sprite and set position for it in windows,but in android this position is wrong.

2- I created 12 sprite in another Page and see sprites don't resize according to screen resolution.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Jan 2015 15:10 Edited at: 12th Jan 2015 15:11
What code are you using to size/position the sprite? Also is this in VIRTUAL or PERCENTAGE?


Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 12th Jan 2015 15:47
this is my code for resize and set position:



I used VIRTUAL.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 13th Jan 2015 16:32
there is any solution?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Jan 2015 16:43
Yes, you are setting the position of the sprites without considering the fact that the device size may change.

You need to use a dimensions relative to the size of the device width and the device height rather than a hard coded value.

For example:



Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 13th Jan 2015 17:39
this code don't work. I increase it until 500 but don't show anything.

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 13th Jan 2015 18:38
Do you need sprites 500 times the width of your device's screen?

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 13th Jan 2015 21:02
I have 2 variable like below:



and multiply them from 0.1 until 500 but do't show anything.500 is only for test.I tried random number from 0.1 to 500 In order that maybe see anything.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 13th Jan 2015 21:38 Edited at: 13th Jan 2015 22:07
Ok, I find it. should only use GetDeviceWidth() and GetDeviceHeight() like below.Now sprite can resize but also Position not correct.



baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Jan 2015 09:14
Yes, you need to position the sprites relative to the size of the device too.


Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 14th Jan 2015 09:41
in above code I set Position relate to Device size that work in windows but in android position is not correct.

for example:

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 14th Jan 2015 10:36
You haven't set the position relative to the entire size of the screen. You have simply positioned it based on a distance from the right hand side / bottom of the screen.

Example:

Imagine we have a device with screen width of 1000.

= one tenth of the screen from the left.

= one tenth of the screen from the left.

However, run the same code on a different size screen, say 2000 wide, and you'll see that *0.1 is still one tenth across the screen (Yay!), but the -900 version will place it just past half way across the screen. I hope this makes sense.

V2 T1 (Mostly)
Uzmadesign
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Jan 2015 11:28
Yes, you need to understand that when positioning something on a screen that may be different sizes on different machines you will need to use a 'variable' value not a hard coded 'constant' value.


Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 14th Jan 2015 20:04
I define two constant variables like this:



then used this code for set Sprite Size:



then used this code for Set Position:



even used this code:



but all thing in windows is ok and in android result is like below Picture:

Yodaman Jer
User Banned
Posted: 14th Jan 2015 20:12
As has been said in other posts, you need to use the percentage system, not the virtual system. Your line here...
Quote: "SetSpritePosition(clonebtn[a],devicewidth-1050+a*200,deviceheight-580"

..should not have that "1050" or "580" in it - you need to use the percentage system. For example, if you want your sprite halfway across the screen, you just use "50" since 50 is half of 100%. I suggest looking into this as it will point you in the right direction!


It's back, baby!
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 14th Jan 2015 20:50
Thanks Yodaman Jer. Already I used percentage system for my games, but most user tell me virtual system is better.so I used virtual system in my Projects.but this project percentage seem work better that virtual. but also I need fix virtual system. because for other Projects may I need virtual system instead percentage.
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 14th Jan 2015 21:11
You don't necessarily need to use the Percentage System, I would recommend sticking with Virtual. But you must understand the difference between a constant value and a variable value. By hard coding numbers like -1050 or -580, the result will be different on devices where the screen width and height are different.

Have another read or two of the post provided by CJB above. Heres the link for clarity...

http://forum.thegamecreators.com/?m=forum_view&t=213223&b=41&msg=2547619#m2547619

This explains it very well IMO...

Using AppGameKit V2 Tier 1
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 14th Jan 2015 22:14 Edited at: 14th Jan 2015 22:15
hehehee

oh.. the entertainment value

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Jan 2015 23:50 Edited at: 14th Jan 2015 23:51
This:

devicewidth-1050+a*200,deviceheight-580

is a constant value that is different on all devices.

If you want to set a sprite to be in the exact centre using the virtual system, you would do this.

1. Set the virtual resolution.
2. Set the sprite position at half the virtual height and half the virtual width, NOT the device height and device width.

e.g

top of program:
setVirtualResolution(1440,900)

Positioning sprite:
setSpritePositionByOffset(mySprite, 720, 450)

or even better:
setSpritePositionByOffset(mySprite, getvirtualwidth() / 2, getvirtualheight() / 2)

Quidquid latine dictum sit, altum sonatur
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 15th Jan 2015 00:10
That's helpful, BatVink

Onwards and sometimes upwards
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jan 2015 09:11 Edited at: 15th Jan 2015 09:15
The virtual system can work the SAME as the percentage system, in fact that's the key:

global PercentWidth as float
global PercentHeight as float
PercentWidth = GetDeviceWidth()*0.01
PercentHeight = GetDeviceHeight()*0.01

Then to set a sprite up as half the height and width of the screen:

SetSpriteSize(spriteID, PercentWidth*50, PercentHeight*50)

EDIT: simplified my post


Using AppGameKit V2 Tier 1
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 15th Jan 2015 10:36
If sticking with a "Stretch to fit" percent solution, you can also use:

dwidth# = GetDeviceWidth() * 1.0
dheight# = GetDeviceHeight() * 1.0
SetDisplayAspect(dwidth# / dheight#)

This will set the aspect ratio to fit whatever device you are using.

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 15th Jan 2015 15:07
Quote: "The virtual system can work the SAME as the percentage system, in fact that's the key:

global PercentWidth as float
global PercentHeight as float
PercentWidth = GetDeviceWidth()*0.01
PercentHeight = GetDeviceHeight()*0.01"


with use above code or Previous code I have same Problem for set Sprite Position.Problem is when I Set spritePosition like this:



or



or



Sprite no set at current Position in Android.

but when I use
and set spritePosition all position are correct in windows and android. seem use VIRTUAL make exist Problem.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jan 2015 15:51 Edited at: 15th Jan 2015 15:54
You are still using "magic numbers" such as those shown in BOLD:
SetSpritePositionByOffset(clonebtn[a],PercentWidth*0+(a*200),PercentWidth*10)

SetSpritePosition(clonebtn[a],-40+a*200,50)

SetSpritePosition(clonebtn[a],devicewidth-1050+a*200,deviceheight-580)

Where do the 1050, 200, 50 and 580 values come from? They are not being used relative to the device size in any way.

Perhaps you should stick to the percentage system as it is working for you until you are a little more experienced and understand why you keep making the same mistake?


Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 15th Jan 2015 16:12
Quote: "Perhaps you should stick to the percentage system as it is working for you until you are a little more experienced and understand why you keep making the same mistake?"


I think your right. should I use percentage system and get more experience.

but I possible tell me where is Problem?how can fix it?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jan 2015 16:40 Edited at: 15th Jan 2015 16:41
I'll use your first example:
SetSpritePositionByOffset(clonebtn[a],PercentWidth*0+(a*200),PercentWidth*10)

PercentWidth*0 is not needed.

(a*200) needs to be something like (a*PercentWidth*10)

The next example:
SetSpritePosition(clonebtn[a],-40+a*200,50)

-40 needs to be based on PercentWidth, as does the a*200 (similar to the last example. 50 needs to be based on PercentHeight.

The last example:
SetSpritePosition(clonebtn[a],devicewidth-1050+a*200,deviceheight-580)

devicewidth-1050 should be something like devicewidth-(PercentWidth*80). deviceheight-580 needs to be something like PercentHeight*70.

The numbers we use for PercentWidth and PercentHeight may need to be calculated (rather than guessed) from the image size you are using. For example if 200 is an image width and we know the background image width we can do something like:

( a * 200 )
becomes
( a * ( PercentWidth * (200.0/backgroundSpriteWidth#) * 100 )


Using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-11-25 15:52:13
Your offset time is: 2024-11-25 15:52:13