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 Collision Detection Help

Author
Message
PDesigns
11
Years of Service
User Offline
Joined: 31st Jul 2013
Location: Austin, Texas
Posted: 1st Aug 2013 00:06
Hi there guys,

I am working on Tier 2 using Xcode to develop for iOS.

This line of code checks if the pointer was pressed, when its been pressed it collects data as to where. It then checks those values to the position of the sprite.

Im getting no errors or warnings, what am I doing wrong.




Thanks
Georhe
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 1st Aug 2013 10:19
is it returning 0?

perhaps you should use agk::GetSpriteHitTest(SpriteID,x,y); and scan each individual sprite

have you moved the viewport at all? maybe use agk::ScreenToWorldX(GetPointerX());

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Aug 2013 10:49
@PDesigns: what exactly is the problem and what is supposed to happen? Also which version of AppGameKit are you using?

Also, is GetPointerPressed definitely what you're after, as opposed to GetPointerState() (repeatedly returns 1 while being pressed)?

PDesigns
11
Years of Service
User Offline
Joined: 31st Jul 2013
Location: Austin, Texas
Posted: 1st Aug 2013 20:48
Thanks for the replies.

I am using the most recent version with Xcode developing for iOS

Here is the code with GetPointerState



When the user has touched the screen the statement should run collecting the values for where the pointer was pressed. It then runs those values where the pointer was pressed to see if it matches the Bug Sprite location (Which is random)

If it has hit the bug then a sound will play, score added too and a new bug generated.

I am not sure how to tell what the GetPointerState() function is returning

Hope that helps a little
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 2nd Aug 2013 00:05 Edited at: 2nd Aug 2013 00:06
Quote: "I am not sure how to tell what the GetPointerState() function is returning"

You can simply print them with the agk:: Print(); command. Chuck this in your app::Loop(), it's very important for you to know what they're returning.



One important thing to remember about the GetSpriteHit command is that it will return the most front/top sprite. If you have a sprite overlapping your target sprite then it may return that overlapping sprite. GetSpriteHitTest may be worth a shot.

Oh, and welcome to the forums.

PDesigns
11
Years of Service
User Offline
Joined: 31st Jul 2013
Location: Austin, Texas
Posted: 2nd Aug 2013 00:33
Thank you Hodgey!

GetSpriteHitTest() worked like a charm!

So far AppGameKit has been a wonder, looking forward to working on some games

Login to post a reply

Server time is: 2024-11-24 18:47:36
Your offset time is: 2024-11-24 18:47:36