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 / How to get real-world coördinates of sprites that have been added to a Skeleton with FixSpriteToSkeleton2D?

Author
Message
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 24th Jun 2021 15:23 Edited at: 24th Jun 2021 15:26
Hello all,

I'm currently helping my son make a game, where he draws stuff and I animate it using Spriter. I'm new to using Skeletons and have trouble detecting collisions. In this thread, I was given (helpful!) advice to add sprites to my skeleton with the FixSpriteToSkeleton2D-command and use these as hitboxes. I've added several of them, but now I encounter a new problem: As you can see in the attached image, I've added several sprites to one of the Skeletons (I've made two of them visible in this picture, located at the arms of the red monster). However, the GetSpriteCollision-command doesn't detect anything if I check it against the mummy, which is a regular, non-skeleton animated sprite.

Perhaps it has something to do with the offset of the sprites I attached to to the Skeleton? As the debug-text shows, the X and Y-coördinates of all the sprites are set to 0,0... They don't reflect the 'real world' coördinates. Is there something I can do about this? Perhaps I am missing something...?

Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 24th Jun 2021 20:24
Without seeing your code I've only a guess but it seems the sprite x,y is local to the bone so it will always report 0,0, try using the bone location, as far as I know GetSpriteCollision should work, its been a while since I used this stuff so my memory is foggy but I'll have a play here and see if I can figure it out, I'm pretty sure I just attached a sprite as hitboxes.

Maybe because its attached to a parent it needs a physics shape for the collision, not sure Ill have a play
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Jun 2021 21:34
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 25th Jun 2021 08:10 Edited at: 25th Jun 2021 08:55
Hi PartTimeCoder and blink0k,

thank you for assisting me! I have been able to use the command GetSpriteHit() to check if the X and Y-coördinates of a bone hit the Mummy-sprite. While that seems to work, it only detects a single location. Ideally, I would like to detect a proper "sprite on sprite"-collision.
I've attached my project with the media to this post as well as the raw code below.

The GetWorldXFromSprite() command seems to keep reporting 'local' values (e.g. 10, 10)... I'm probably not using it right. (I've changed lines 344 and 345 with "sx# = GetGetXWorldFromSprite(s, 0, 0) )



Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-26 15:41:07
Your offset time is: 2024-04-26 15:41:07