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 / Changing sprites color bassed on position not very accurate.

Author
Message
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 10th Nov 2022 22:46 Edited at: 10th Nov 2022 22:58
So I am trying to change sprite colors if another sprite is in its same position, the second sprite has nothing to do with the first other then its pos/

This is how I am choosing that sprite to change color, if the positions are the same, if they mach then the sprites color changes.

I am using this here that I changed a lot to get it to work and it well, works about 90 percent of the time.

note. the sprites I am matching positions with are deleted after the color change so I think this might be the case but I added a tween delay and noticed it is now about 95 percent working. As in the colors change about 90 percent. Here and there the sprites do not change, and well, they should, there is no reason for them not to other then AppGameKit is not very accurate. There is nothing at all holding them from changing colors. Other then one, and this could be some how the other sprites are not at the same positon, but there being placed in the same spots.

Any help or advice would be well, appreciated.


Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 11th Nov 2022 01:52
Don't go by exact pixel perfect positions, add a margin of error to give a bit of wiggle room (an approximate position).
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 11th Nov 2022 02:01
Quote: "Steve Ancell"


Ok , I will try this, and find a ballance if possible, thank you for the help, ill let you know if it helped.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 11th Nov 2022 02:57
Ok, i just changed this to sprite collison and it works 100 percent everytime, here is my easy fixed code . I guess dealing with positions it is never 100 percent.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Nov 2022 06:41 Edited at: 11th Nov 2022 06:47
Quote: "backgrounds[A].Sprite_X# "

assuming you left .Sprite_X# as Float in your Type, you're comparing at a Sub-pixel level. IE, use INTs, instead.

then, if there's a chance that things can move more than a single pixel, get even more fuzzy/"approximate" as mentioned above.

and, if both objects are moving, then.... well, we don't know what (all) might be moving and by how much, so...

meanwhile, seems you've got things working... onward!
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 11th Nov 2022 13:59
Quote: "assuming you left .Sprite_X# as Float in your Type, you're comparing at a Sub-pixel level. "


It was a float in my type, wow that sounds like a drink Can I get a "Float in my type please?"

Login to post a reply

Server time is: 2024-11-21 13:07:10
Your offset time is: 2024-11-21 13:07:10