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 / GetSpriteHit & GetSpriteHitGroup in 107

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 7th May 2012 12:43 Edited at: 7th May 2012 14:50
GetSpriteHitGroup() & GetSpriteHit() are working differently in 107 then they used to be in 106.

While GetSpriteHitGroup() returns the last sprite number in the sprite redraw order, GetSpriteHit() returns the first sprite drawn, when there are overlapping sprites on the same depth.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 7th May 2012 14:01 Edited at: 7th May 2012 14:50
Do these work like this on purpose?
is there anything wrong? (they worked differently in 106)
or am i doing something wrong, now that 107 changed the redraw order of sprites on the same depth?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 7th May 2012 15:24
I had a lot of problems with SetSpriteDepth() on 106. Sprite order was getting all over the place whenever SetSpriteDepth() was called.

with 107 this seems to be working great, the way it makes sense!
even without setting SortOrder!!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 19:55
I have around 320 sprites.

after around sprite number 256, GetSpriteHit() is not returning the right sprite hit number
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 8th May 2012 21:46
in 1071 theses functions don't work anymore ... It will be fixed in the next release
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 22:09
oh no!!!!!

any idea when 1072 will be out now?

I had to fix all my code using a combination of GetSpriteHit & GetSpriteHitGroup to get thingsto kind of work in some way in 1071...

And now the behaviour will change again?!!!!
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 8th May 2012 22:50
No .. it will work as expected it's already fixed by paul
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 23:23
sounds great.

now the most important question arises: when will 1072 come out?

my whole project now depends on GetSpriteHit! All teh other stuff seems to be working great (apart from GetImage on iphone 3gs)
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th May 2012 23:42
Yah, I reverted to 1065 so I could keep working until 1072 comes out.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 14:49
Just installed 1072.

this fixes nothing.

GetSpriteHitGroup() & GetSpriteHit() still work the same as in 1071.

after around sprite number 256, GetSpriteHit() is not returning the right sprite hit number.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 16:49
MikeMax, did you try 1072 yet?
Did GetSpriteHitGroup() & GetSpriteHit() work for you?
RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 9th May 2012 16:58
I have asked Paul to take a look, he thinks he did fix it but will check now.

Rick

Financial Director
TGC Team
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 9th May 2012 17:02
We could use some sample code to prove the difference in behaviour. Something in a few lines so we can get to the crux of the functional difference and resolve it for 1073.

I drink tea, and in my spare time I write software.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 17:22
I am still trying to sort out what is causing the main problem.

I have added another 100 sprites in my project and these work fine!!!!

but there is still a selection of sprites that do not report a correct GetSpriteHit()

however i can confirm that GetSpriteHitGroup() returns the last sprite number in the sprite redraw order, GetSpriteHit() returns the first sprite drawn, when there are overlapping sprites on the same depth.

i just want to know if this is the way these commands are intended to work or if there's a problem why they don't both return the same sprite (either last in depth or first in depth)
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 9th May 2012 17:22
The SetSortCreated() fix offsets the depth in intervals of 255 meaning that it can handle 255 sprites at the same depth and still distinguish an order. If you need more than this with a defined order it is recommended that you use SetSpriteDepth to separate them.

Unfortunately I can't increase the interval higher than 255 as there isn't enough accuracy in the depth buffer to support 10,000 depth values + 255 intervals for every depth level.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 17:24
Paul makes sense, good to now this.

I am not using SetSortCreated() though
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 17:25
Paul 1 last question:

Can you condfirm if GetSpriteHitGroup() returns the last sprite number in the sprite redraw order & GetSpriteHit() returns the first sprite drawn, when there are overlapping sprites on the same depth.

Is this the way they are intended to work? Shouldn't they both return the same sprite, either last or first in depth?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 17:31
I have split sprites on different depths. I only have upto 40 sprites on 1 depth layer.

Still same exact problem with GetSpriteHit() though
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 9th May 2012 17:33 Edited at: 9th May 2012 17:33
Looking at the code there is indeed a difference, one compares for depth less than, the other does less than or equal. Is the current functionality of GetSpriteHit() or GetSpriteHitGroup() more useful? I'll make the other equal the result of that.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 18:10
Thanks for looking that up Paul.

I think both commands should return the sprite that shows topmost on the screen, which I think is the sprite you CreateSprite last if i am not wrong.

So if i have 3 sprites overlapping, and I click, the return value would be of the only sprite that shows all (top one).

In the future maybe there could be an extra set of GetSpriteHit() & GetSpriteHitGroup() commands to return the bottom most sprite on screen, or the sprite you CreateSprite first, so that depending on the circumstances, every option

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 18:13
The other GetSpriteHit() problem is a very strange one.

This happens when you have a lot of sprites loaded.

I split them over different depths (40 per depth) and the problem was still there.

I found at which particular sprite number, GetSpriteHit() was not working anymore, and at that point I loaded 30 blank empty sprites! After that point, all the other sprites worked well!!!!

This is very strange, and I don't know if its easily replicable, but for now it will stay that way as I want to complete my project.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 18:33
I put this code at the point where I was loading the sprites where GetSpriteHit() was not loading.



Now all sprite hit checks work!

Seems very weird and strange!!!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 18:39
I checked the Sprite numbers of the sprites that were not returning the correct GetSpriteHit(). Sprite numbers after 10240 do not work. Sprites after 10273 work again!!!!

Very weird!
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 9th May 2012 19:14
That makes sense, the structure used to store sprites is an array of linked lists, a compromise between fast access and dynamic memory. The array is 1024 in size, so sprite ID 1025 would be stored back in array element 1 as part of a linked list. This means that getting the sprite list to check for collisions returns 1,1025,2,3,4,5, etc.

This is the reason SetSortCreated() should be used if you absolutely want correct ordering at the same depth. I could probably create a global linked list along side this purely for traversing all the sprites which would solve all these problems.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 19:30
Paul SetSortCreated(1) solved the problem!!!

Thanks for all the background info!

I wouldn't add any global linked list checking if this would entail an extra overhead to the system.

This is the only project I have where I need around 40 sprites on 1 depth. In other projects I am putting every sprite on its own depth
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 21:39


In this picture there are 3 sprites on top of each other.

If you click in the centre, the sprite number returned by GetSpriteHitGroup() & GetSpriteHit() should be the orange circle not the blue ones
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 11th May 2012 06:15 Edited at: 11th May 2012 06:20
totally agree with the bjadams picture.

For me now, GetSpriteHit works fine but ONLY on windows in 1072 (it didn't work in 1071 at all). (i have not tried the MacOS Player version for the moment).

But i have recompiled the Android Player and the iOS Player 1072... and GetSpriteHit isn't fixed (none of both)... even with a SetSortCreated(1). I'm using dynamic sprites with world coords and scrolling etc... i have not tested fixed sprites.

I only want to get the top-most sprite ... the FIRST visible ! the one which is FRONT of our eyes ! (i think users usually won't want a sprite that they don't see no ? except special cases like level editors ..)

I see Two functionnalities :

- GetSpriteHit(x,y) : Return the "TopMost" Sprite ID we've touched or clicked (as before !).
- GetSpritesAtXY(x,y) : Returns an array or object of all levels of sprites present at x,y with their associated depths :p
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th May 2012 12:20
Would love something like GetSpritesAtXY(x,y) in the future
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 11th May 2012 12:49
Hi,
I confirm the getSpriteHit() works erratically on Windows.
The following code:

return touchedNote=0 even if a sprite is clicked, while sometimes the same click returns the correct sprite ID.
There are not overlapping sprites in this case (and in fact 0 is returned).
On the other side, the Android version works perfectly on my Samsung Galaxy Gio.
It seems another kind of bug...
I am using a fresh AppGameKit 1.072 installation. I managed to compile AppGameKit player without double icon my removing the lines addressed by Paul in the manifest file.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th May 2012 15:15
Quote: "Would love something like GetSpritesAtXY(x,y) in the future"

I did a function for this where all I did was:


...or something along those lines

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th May 2012 15:57
Baxslash as much as I you, that function would be overkill having to loop through all sprites!!!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th May 2012 16:36 Edited at: 11th May 2012 16:37
I just tested it and I only get a slow down when there are more than 400 sprites in the test position.

EDIT: Having more than 400 sprites in one position could be considered overkill

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th May 2012 16:42
I thought it lopped through ALL sprites!!!
My mistake!!!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th May 2012 16:44
Ah, that would be crazy

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th May 2012 12:50
GetSpriteHitGroup() & GetSpriteHit() seem to be working great now
chrisnob
11
Years of Service
User Offline
Joined: 3rd May 2012
Location: Leeds - UK
Posted: 15th May 2012 15:17
GetSpriteHitGroup() is still not working for me and it's not been working since 1065.

I've tried every 107 release so far and it's becoming quite frustrating uninstalling 1065 and trying the latest 107x build. I've tried it on both Samsung and HTC phones and it's not working.

The code works on Windows but when I build an Android Player or build my app for Android GetSpriteHitGroup()always returns 0!

I tried removing my calls to SetSpriteDepth but it's not made any difference.

Are there still bugs with GetSpriteHitGroup()?

Are the 107x releases beta releases?

Thanks
--
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 15th May 2012 17:27
If you are using the player from the Android store it has not been updated yet.

Quote: "Are the 107x releases beta releases?"


In hindsight, yes. 1074 will be out shortly which we expect to be the final version.
chrisnob
11
Years of Service
User Offline
Joined: 3rd May 2012
Location: Leeds - UK
Posted: 15th May 2012 17:41
I have not been using the player from the Android Store. I have been building the player from the source code in each release.

The built player works and loads my game but GetSpriteHitGroup() and GetSpriteHit() just don't work.

My compiled game APK also loads on my Android devices but doesn't work either, GetSpriteHitGroup() and GetSpriteHit() just return 0.

At present I can get away with compiling using the 1065 source but I really want to use the GetResumed() function for release.

I will try again when 1074 comes out.

Thanks for the reply.
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 16th May 2012 00:04
Build 1074 imminent

I drink tea, and in my spare time I write software.
chrisnob
11
Years of Service
User Offline
Joined: 3rd May 2012
Location: Leeds - UK
Posted: 16th May 2012 15:23
I am pleased to say that GetSpriteHitGroup() and GetSpriteHit()are now working for me in 1074.

Thanks for the update.
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 21st May 2012 12:51
getSpriteHit() don't work on Android when the setViewOffset (with percentage) to set to (100,0), (200,0), ecc.
On (0,0) it return the correct sprite number, on (100,0), (200,0)ecc it return the sprite number as it were stuck at (0,0).
In the attached image you can see that getspritehit() return 10003, by clicking on the table. Unfortunately 10003 is the sprite ID of first table, while it should 10004. View offset is (100,0), in fact the fourth line report 146.20, that is the world x coordinate, obtained from 46.20 (second line) adding 100. Moreover clicking on the background, the value 0 is returned instead of 10002 (the ID of the background).
This behaviour did not happen with 1.065.
I could try to recompile everything, but I had 1.074 yet.

Attachments

Login to view attachments
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 21st May 2012 21:47
now it works...

Login to post a reply

Server time is: 2024-04-27 10:04:25
Your offset time is: 2024-04-27 10:04:25