cocos2d/cocos2d-x: Adding tile to the layer - cocos2d-x

Please tell me how to Tilemap on the layer you want to add a tile?
Rummaged through all the documentation and did not find. How to remove a tile layer, I realized:
[_meta removeTileAt:tileCoord];
How to add a tile layer? Prompt please.
Generally I need to become an obstacle selected tile.

You can do this...by
map = CCTMXTiledMap::create("stonemap.tmx");
CCTMXLayer x=map->layerNamed("layer_name")
//layer_name is name you give to your layer Ex...backGround_Layer,Obstacle_Layer

Got answer from here where m_gid is your resources ID :)
layer->setTileGID(m_gid, tileCoord);

I believe there is a Class called CCTMXTiledMap in cocos2d-x. You can add map like this in cocos2d-x in CCLayer:
map = CCTMXTiledMap::create("stonemap.tmx");
this->addChild(map,0,tagMap);

Related

geotools draw symbol on overlay

I'm new to Geotools. I am developing a simple application that shows a map and I would like to dynamically place a bitmap or vector symbol on it (for example to show where the current position is, like in navigation systems).
Now, what I've done already is:
showing a map given one or more shapefile.
center the map on the last inserted position.
add shapes to new layers when needed.
What I need to do is to create an overlay with images at given coordinates on the map area (to be clear, I don't want to generate a raster layer on disk, I just want to paint on the screen).
My guess is that I have to somehow directly use the Graphics2D instance inside JMapPane, is that correct? In this case how can I convert from the geographic coordinates to pixel coordinates on the drawing pane? Or are there some geotools functions/classes that I should be looking for?
Thank you.
Answering myself, since I found the solution.
I did it by extending class org.geotools.map.DirectLayer, which provides a way to define a custom layer by extending its draw(Graphics2D, MapContent) method. Graphic elements are placed at the correct coordinates by using the worldToScreen affine transform provided by geotools. For example, to define a Point2D placed at the current position given real-world coordinates:
AffineTransform worldToScreen = viewport.getWorldToScreen();
Point2D worldPoint = new Point2D.Double(currentPosition.x, currentPosition.y);
Point2D screenPoint = worldToScreen.transform(worldPoint, null);
Once the draw() method is defined, just instantiate and add as a layer to your MapContent instance.

how to zoom/pan automatically to all features in a vector layer?

Using Openlayers, I would like to initialize the map in a position where it shows all the features in a vector layer. How to do that?
This is a little sharp/rough
map.zoomToExtent(yourVectorLayer.getDataExtent());
This may be smoother
map.panTo(yourVectorLayer.getDataExtent().getCenterLonLat());
map.zoomTo(yourVectorLayer.getDataExtent().getZoomExtent());
With OpenLayers 5.3.3 I use this code snippet:
const extent = vectorLayer.getSource().getExtent();
map.getView().fit(extent, map.getSize());

using lineTo in a movieclip having a some shape already

This is quite silly, but still i am scratching my head on this :
mc.graphics.lineStyle(2,0xff0000)
mc.graphics.lineTo(100,100);
mc.setChildIndex((mc.getChildAt(0)),0)
In the above mc is a filled rectangle shape. But when i use lineTo, it draws line at the back of the shape. I tried to use the setChildIndex method, but of no use.
Any suggestions ?
Thanks
V.
graphics is the drawing layer below all children within a component, instead you can create another sprite then add it to the display tree in whatever order you please and draw on it's graphics instead.
Let me know if this doesn't help or isn't clear.
Shaun

Creating the layer functionality in Flash CS5 (as3)

Hi I need to create the application in Flash CS5 with the help of as3 where the user can draw according to his requirement but in layers. This app will provide user to create Business Cards, Broushers etc. Can anyone help me in create the layer functionality. Only the layer functionality of this app is remaining. If anyone one can resolve it please help me out.
The answer you are looking for requires a lot of development time.
The basic idea is to create a stack of sprites and draw on each one of them the shapes or images that you need. Last year I build an application just like that and it took several month to finish.
If you want to build it yourself you should ask much more specific question on how to do things.
You can treat each layer as a sprite and draw into these sprites using the graphics object of each, you can easily change the ordering of the layers by changing the indices of the sprites in the container they are in.
var layer1:Sprite = new Sprite();
container.addChild(layer1);
var layer2:Sprite = new Sprite();
container.addChild(layer2);
layer1.graphics.*** //drawing functions
layer2.graphics.*** //drawing functions
container.setChildIndex(layer1,1); //change ordering
Hope that helps.

Update dynamic heightmap in Away3d 4.x Broomstick

How do I update my Elevation Object when I change the bimapdata of its height map?
I noticed that getHeightAtPosition() updates to the values of the new bitmap, but the Elevation still looks the same..
(I know it is possible to loop through all vertices in the geometry mesh and adjust them based on the bitmap, but the nice thing with Elevation is that you don't have to do that. If it can adjust to the bitmap on creation it should be able to update..)
Ok, I found the answer on the away 3D forum:
http://away3d.com/forum/viewthread/1110/#3808
Basically, you need to change one line in the Elevation class:
Go to elevation.as and change
private function updateGeometry()
to
public function updateGeometry()
then on the render after you change the parameters call
_elevation.updateGeometry();