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 / Touchscreen sprite detection poor

Author
Message
Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 24th Jun 2014 12:37
Just getting back into agk I have found since getting a new motorola moto g running android v4.4.2 the touch detection of my onscreen sprites has become very unresponsive, you have to touch it right in the centre, instead of pretty much anywhere as before on my old htc wildfire sense mobile. I have been running simple tests using getpointerpressed and getspritehit for detection, all fine before on the htc. It is also poor on a cheap tablet allwinner a13 running v4.0.4. I use agk 10819 and 2.3? using the correct players,any ideas.
Thanks
Markus
Valued Member
21
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 24th Jun 2014 12:44 Edited at: 24th Jun 2014 12:45
hmm, i have also a moto g with 4.4.2 and no problem. (ok, 1 with editbox input)
did the sprites overlap? (sprite depth/order?)
did u try GetSpriteHitTest
can u upload example with problem?

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 24th Jun 2014 12:51
Hi,
I have done a simple test since noticing this problem with only a single sprite and a few lines of code and the problem is still there, but is still ok on my old htc mobile, very strange. I will look into further later.
Thanks
Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 24th Jun 2014 13:07 Edited at: 24th Jun 2014 13:17
Just checked the examples game smack it and it seems very poor with that as well having to be very accurate and sometimes press twice, could it be my screen calibration or settings on the phone? I don't have any other phones to try it on.
Thanks
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 24th Jun 2014 20:34
Are you using GetPointerPressed or touch commands?
I've found that the touch commands tend to be more reliable, but on some devices you have to include unknown touch types in the short touch.

I'd just run a simple example:
createSprite(1 , 0)
setSpriteSize(1 , 10 , -1)
do
if getPointerState() = 1
SetSpritePosition(1 , GetPointerX() , GetPointerY())
endif
sync()
loop

If that's not responsive then you might want to report it to AppGameKit support. None of the devices we own have shown problems like this, but I've been told about it from time to time...

Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 25th Jun 2014 19:28
Hi,
I will do further testing and get back as not on my games development pc until the weekend.
Thanks
Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 26th Jun 2014 19:53 Edited at: 26th Jun 2014 19:54
Just had 5 mins on pc, even the example "position a sprite whenever the use touches / clicks the screen" places the sprite off to the right a sprite width and down a sprite height of my finger position, basically top left of the sprite, is this correct?

The screen reacts correctly to the getpointerstate and getpointerpressed commands in my test prog but you have to be touching about dead center of the rectangle sprite button for it to detect it being touched, I am also using GetSpriteHit(GetPointerX(),GetPointerY()) but will try other at weekend when I have time, strange as I say used to be fine on my old htc.
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 26th Jun 2014 20:45
I never liked / trusted GetSpriteHit it always seemed to just not be accurate enough (I agree it still should work). Try GetSpriteHitTest()

baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 27th Jun 2014 16:18
I use GetSpriteHit / GetSpriteHitTest / GetSpriteHitGroup etc. all the time and they are very accurate to the shape assigned to a sprite. You can check the collision shape using setPhysicsDebugOn. This shows the shapes assigned to none physics sprites too. What you have to look out for is using worldToScreenX/Y and screenToWorldX/Y when necessary.

I haven't had any accuracy problems at all with those commands.
Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 28th Jun 2014 17:04
I can't get this to work accurately, I have even put a single large ( 250 x 250 ) sprite on screen to check where detection is being picked up. It seems to miss about 25% of the sprite from the edges before it triggers, with small game sprite that makes it very difficult to get a trigger/hit. Any ideas as it's doing my head in. I am broadcasting to my moto g mobile and cheap allwinner a13 tablet, it is also has same prob with apk file install, what the hell is going on?

Thanks
Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 28th Jun 2014 17:22
UPDATE:
The only way to get something to work is to set up a very small invisible sprite at getpointerx getpointery minus offsets as sprite doesn't line up with pointers xy positions then check invisible sprite collision with other sprites, this works but I shouldn't have to do this, it looks like I have problems with getpointer commands for some reason, I don't know why.
Thanks
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 28th Jun 2014 20:18
If you're using AppGameKit 10819 are you sure you're using the player for 10819? If you got the player from the Play Store then it is probably the one for 10821.
It really shouldn't matter though.

Just in case there is confusion: When you move a sprite using GetPointerX and GetPointerY the sprite's upper left corner is set to that position.

What happens if you just run a program like this:
do
Print(GetPointerX())
Print(GetPointerY())
Print(GetPointerState())
if GetPointerPressed() = 1
pressTime# = timer()
endif
Print(pressTime#)
sync()
loop

This is a disturbing issue and if the above code is not yielding expected results then you should contact TGC support and let them know of the issue. The Moto G is a fairly popular device and this stuff should all work.

Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 29th Jun 2014 16:13 Edited at: 29th Jun 2014 16:16
Hi Naphier,

The getpointerx() and getpointery() give the correct coordinates print out, getpointerpressed() is correct in returning 1, also elapsed time is correct.

Are you saying that the sprites top left corner will always be at the getpointerx() and y() coordinates, and this is normal?

I have 2 versions of agk in separate folder on my system, the correct players are being used, it was the first thing I checked.

I may do a fresh install of only v10819.

Thanks
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 29th Jun 2014 19:41
I'm saying that when you SetSpritePosition(spr , x# , y#) that x# and y# refer to the upper left corner of the sprite, so SetSpritePosition(spr , GetPointerX() , GetPointerY()) will always put the sprite to the right and below your finger (for the most part). If you want to position the sprite by it's center use SetSpritePositionByOffset() the default offset is the center of the sprite.
If GetPointerX/Y and pressed and state are all returning values correctly then there is no reason that GetSpriteHitTest() shouldn't be working because it is essentially the same as using:


The same goes for GetSpriteHit, but that simply iterates through all of the sprites instead and chooses the sprite with the frontmost depth first.

If Markus isn't having any issues then there's got to be something specific to your setup.

Pumpkin Software
AGK Developer
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location: uk
Posted: 29th Jun 2014 21:02
Hi,
Yes I understand that sprites will be placed at top left of xy coordinates unless using offsets, sorry I wasn't clear about what I was asking.

All sorted now, I installed agk on our workshop pc and everything is working for my moto g as it did on my old htc. I think as I came back to agk at the same time as getting the new moto g I wrongly thought this was the problem as all was ok before on my wip games.

I will clear my agk and traces on this pc and do a fresh install.

Thanks for everyones input.
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 29th Jun 2014 23:15

Login to post a reply

Server time is: 2025-05-25 15:57:41
Your offset time is: 2025-05-25 15:57:41