the class, at runtime, once you pass it a coordinate x,y on the map (the x,z of the camera in ratio), reads the colormap.
if a color is found that you have declared, it fires an event.
so the class doesn't handle the collision
if you set say where your table is a yellow region on that map
basically after you have set the "color" listener, it triggers on the yellow reading
collisionmap = new CollisionMap(mycolormap, this, 1 , 1); //here 1/1 ratio on x and y. if your floor is say 2048x2048 and map 1024x1024, pass 2,2
collisionmap.setColorEvent(0xFFFF00, "yellow", onYellow);
private function onYellow(event:Event):void
{
trace("WARNING this is an valuable furniture, look out!!";
}
what you do with the collision reading, is up to you. Bartek, for instance, for its circuit game, used a similar construction
where the color was different from the main road. --> slowDown();
but when it comes to real collision handling, i would consider take a look at BSP generation as David suggested,
in fact thats the reason why we've spend the time and effort to make it in the first place.
as a side note, take care making the colormap, if you use flash lib and the source is not a vector info that you draw, that
compression, might influence the colors. so no event is triggered. So either you apply a custom threshold to the class,
or the easy way, test the colors at locations you know the exact color. There is a getter just for that reason in the class.
Fabrice
Fabrice
reading at your previous questions, these were as3/synthax related issues.
wrong params to constructors or wrong types..
Are you still stuck with the same issues?
Fabrice
best regards
trace your x and -z when you ask the "read"
they are probably exceeded the bounds of your map.
try attach on top of your scene this map or a duplicate, and setPixel at this coords...
i bet you are way off.
Fabrice
then, this is important make sure the color you test on IS the color you think it is...
make a test at a position on the map you know its say "yellow"
check the reading value and the one you entered for the event.
due to compression algo's if you use a bitmap color might change
fix is to draw with vector movieclips, and draw this movieclip into bitmap runtime.
again, to test addchild your map above, and plot the readings and trace the colors to see if correct
the class as a special test call for this purpose --> doc
Fabrice
its confusing but very simple. Try think from top of your scene that the -x and -z of your sceneobjects bounds
are the top left on the map, the x and z of the object must be the downright. if your map is smaller than the object bounds units
just define the factorX and Y in ratio.
Fabrice