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.

Newcomers AppGameKit Corner / Quick Sprite question - spritehit

Author
Message
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Aug 2017 02:49
I feel bad for blowing up the forum.. but I just can't find this answer.

I have two sprites set at the same position. One is hidden, and should be "deactivated" until its visible. I have tried to set the depth lower than the other sprite. But it still interferes with the spritehit command.

The sprite is a backpack. Once hit, it triggers opening the inventory. The exit button then appears. The problem is I moved them both to occupy the same location. Now, I am unable to hit the backpack icon if its on the same location, even though, I set the exit button depth below the backpack icon depth.

I have lots of sprites on top of each other, but I have them set to groups and I use the gethitspritegroup command... this is the only one giving me fits(and coincidentally I do not have them set as groups).

Surely, there is some way to deactivate a sprite? I looked at setspriteactive but that seems to only affect physics and animation. Is my only option to load the exit button and then delete the sprite every time I open and close? My inventory "script" already seems to be pretty intensive. I fear doing this will cause lag (granted that may be baseless I have no idea).

Hoping to hear your experiences or any tricky solutions.
Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 29th Aug 2017 04:12
I remember having similar issues in the past using getspritehitgroup and I replaced by SetSpriteCategoryBit and GetSpriteHitCategory which imo have more flexibility to handle. Just remember to add and remove each sprite for each category.

Maybe someone might have more tips for using getspritehitgroup though.

Post your progress Golelorn!

Best!
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 30th Aug 2017 18:14
Quote: "this is the only one giving me fits(and coincidentally I do not have them set as groups)."

are you saying the backpack is not set in a group?
easiest solution is make the backpack and the other sprite different group numbers and use GetSpriteHitGroup just like you do with all the other sprites.

if it is already a group then technically it's a bug as the help says it should take depth into account.
Quote: "GetSpriteHitGroup
Description
Returns the ID of the first sprite found under the point x,y in world coordinates. 0 if none. Sprites are ordered by depth so a sprite appearing above another in the draw order will be returned instead of the sprite behind it."

but i've never had any issues using groups so might just be a mistake?

otherwise you can use
SetSpriteCategoryBit and GetSpriteHitCategory
as richard_6 suggests - works exactly the same as groups for general use.
life\'s one big game
spec= 2.6ghz, 1gb ram, 512mb gpu, directx 9.0c, dbpro and classic
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 30th Aug 2017 20:55 Edited at: 30th Aug 2017 21:25
Its not working because the other sprite is above it blocking detection. I was just saying that I don't have that problem with other sprites. I have things beneath them, and they work.

Setspritedepth is not setting it underneath for detection purposes. Wondering if there is a way to set collision off for a sprite like we can in 3d.
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 31st Aug 2017 14:20
to turn off collision for sprites use SetSpriteShape(id,0)
life\'s one big game
spec= 2.6ghz, 1gb ram, 512mb gpu, directx 9.0c, dbpro and classic

Login to post a reply

Server time is: 2024-04-27 00:16:14
Your offset time is: 2024-04-27 00:16:14