I was coding a sort of tile map editor for one of my game with cocos 0.5.5
I needed to be able to refresh one tile whenever the user click on it and
modify it. So i searched into the doc, and i only found the set_dirty
method (for my cocos.tiles.RectMapLayer object)
This method is refreshing the whole map (by calling the
"_update_sprite_set" method in cocos.tile.MapLayer) , and i need to refresh
only one tile.
After looking into both the api doc and the code, i concluded that there
were no methods to do that (to refresh only one tile).
Am i missing something ?
So i just added my own method in cocos.tiles.MapLayer :
def set_cell_dirty(self, cell):
> '''
> Just force one existing cell to be refreshed (and not the whole
> map)
> Assuming you already changed it's tile reference
> '''
> cx,cy = key = cell.origin[:2]
> self._sprites[key] = pyglet.sprite.Sprite(cell.tile.image,
> x=cx, y=cy, batch=self.batch)
I think such a method really lacks in cocos. Though, it's not a difficult
method to programm, i searched for it for like half an hour, assuming it
was already existing somewhere.
Why not including it ?
It could be useful for any game with dynamics maps ... etc
PS :
I could be using Tiled and .tmx maps instead of coding my own tile editor
you may say,
but in my game, the players have to design their own spaceship plans, so
this editor is part of the gameplay and it must be 'ingame'
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/cocos-discuss/-/n1yiYtYuJKwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cocos-discuss?hl=en.