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.

Windows / Problems with selecting sprites in tier 2

Author
Message
Alex4292
6
Years of Service
User Offline
Joined: 21st Mar 2018
Location:
Posted: 21st Mar 2018 16:40
I am currently working on making a version of the game Risk. I have created a map and have individual sprites for each country. I am using the getSpriteHit function when the user clicks to figure out which country has been selected. The overlapping area of the sprites is transparent on the screen (the white background has been removed), but getSpriteHit still picks up on this transparent part. I having been trying to find a way to see if the pixel that the user clicks is transparent so that I can artificially "click through" to the actual sprite but have not been able to do so. Any suggestions?
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 22nd Mar 2018 16:39
try set it to polygon shape with SetSpriteShape(id,3)
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 22nd Mar 2018 21:45 Edited at: 22nd Mar 2018 21:55
The sprite polygon shape only supports up to 12 points so trying to represent a country's outline with with such a rough approximation probably wont give great results but might just be enough depending on your country shapes.

The method of using a colour channel (alpha value for instance) works ok. I used a single image for a map where the country code was embedded in another image of the same size. Then a lookup of the pixel value for the colour gave you the country.

I used a memblock to look up the pixel value at an x/y coordinate. It was in teir 1 but would work in teir 2 also...



Look up the alpha...index that into a Country array and it was done.

In teir 2 there are a few extra functions which return a pointer to an image so you can do the lookup into the image data in C instead of using GetMemblockByte() etc...

In your case you would be checking if the sprite colour was white and then cancelling the sprite hit. Thats would mean you might need to lookup into memblocks for all your countries though.
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 23rd Mar 2018 15:13
True and it doesn't like convex shapes so you may well get issues with that too.
Another option is to use the AddSpriteShape commands to make your collision boxes more precise.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 23rd Mar 2018 15:58 Edited at: 23rd Mar 2018 16:00
Even with adding shapes it all has to be manually coded to get the shape you want and its not pixel perfect whereas a colour lookup is and is fairly quick to implement and the shapes can be based straight ftom the artwork so no extra work

Heres a Basic example of it attached. (not all the countries are named and coded im my example...just what i could do in 10 mins)

Attachments

Login to view attachments
Alex4292
6
Years of Service
User Offline
Joined: 21st Mar 2018
Location:
Posted: 26th Mar 2018 17:21
I was able to use memblocks to get the alpha value and make it work. Thanks for the help!
John Parker
6
Years of Service
User Offline
Joined: 27th Mar 2018
Location:
Posted: 27th Mar 2018 18:51
The shape is not like convex that is why you may face issues. The best option is to use AddSpriteShape commands if you do not want to face a problem. I also have a website which helps you to get the solution of problem-related to any of the email accounts through Rackspace Customer Support so that you can contact with technical service providers and solve the issues in a specific time.

Login to post a reply

Server time is: 2024-11-21 13:28:45
Your offset time is: 2024-11-21 13:28:45