MattTuttle/HaxePunk — pull request #70 by scriptorum (2013-03-26 04:11:27+00:00)
Title: Fix class cast error when reusing bitmap for Atlas then TileAtlas

On CPP targets, add an Image (say, with a clip rect), then add a Tilemap using the same bitmap. This throws a class cast error in TileAtlas:

```Haxe
if (Atlas._atlasPool.exists(source))
{
atlas = cast(Atlas._atlasPool.get(source), TileAtlas);
atlas._refCount += 1;
}
```

If you switch it so the Tilemap is created before the Image, the problem goes away. The reason for this seems to be that _atlasPool holds both Atlas and its child, TileAtlas. TileAtlas assumes that the existing entry in this pool is a TileAtlas, and tries to cast an Atlas to a TileAtlas. Not sure if this is the best solution, but what I did was convert the Atlas on the spot to a TileAtlas.