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 / Sprite Locations Confused - GetSpriteHitGroup

Author
Message
SMS
19
Years of Service
User Offline
Joined: 2nd Dec 2004
Location: United States
Posted: 12th Dec 2011 07:32
Hi All...

When I move my viewport... my sprites move with it, as desired... but when I go to touch those sprites, the GetSpriteHitGroup() command does not see the sprites in their new locations.

If however, I remember where the sprites WERE, and I click there, then GetSpriteHitGroup works!

Is this a bug???

How can I address this?
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 12th Dec 2011 08:39
You need these two code:


When you moved viewport, the location of sprite changed, so you need to use ScreenToWorldX to transform it.

The Miracrea Games
SMS
19
Years of Service
User Offline
Joined: 2nd Dec 2004
Location: United States
Posted: 12th Dec 2011 09:45
Thanks halley...

I tried putting the code in as is, after the sprite moves are done... and it error's out.

Could you please explain a little more on how to use it?

Thank you!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Dec 2011 10:26
Here's a quick example in Basic:


I'm writing a tutorial on this part of AppGameKit for next month's newsletter (hopefully) which might help explain the whole world / screen thing a bit better...

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 12th Dec 2011 18:29
There appears to be a bug in the sprite detection (bug report [link]http://code.google.com/p/agk/issues/detail?id=163[/link] )

Essentially getting real world coordinates returns sprites with the same screen coordinates, even if the world sprites are nowhere near.

Here's a little something which demonstrates the effect
Needs project screen to be at least 480x800 resolution as it was designed to test on my phone

(Project attached for the copyingly challenged )

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-22 19:40:41
Your offset time is: 2024-11-22 19:40:41