This site requires JavaScript, please enable it in your browser!
Greenfoot back
Gevater_Tod4711
Gevater_Tod4711 wrote ...

2012/9/23

Search for color near the actor

Gevater_Tod4711 Gevater_Tod4711

2012/9/23

#
Hi All, I need help with a method which finds the nearest point to an actor where a color is. It should work like getObjectsInRange or something like that. Just with colors instead of Actors. Any ideas?
danpost danpost

2012/9/23

#
A method like that would probably take up way too much CPU time and slow down your scenario. Also, it would be a very complicated method to write. It would be even more complicated if the color could be from another actor as well as from the world. I was thinking about creating actors for each possible point that could be found; but, even that would require a multitude of transparent pixel-sized actors. These actors, however, could be rotated to indicate the slope of the edge at that point (I noticed you were looking at the 'Gravity Engine' scenario). You could then use 'getObjectsInRange' with an increasing range to find the closest point in question. As an added benefit, you can use the rotation of that point to aid in determination of a new direction (twice the rotation of point minus rotation of this would be the new rotation of this for a standard bounce).
You need to login to post a reply.