How to make mystery box like in mario games in Tiled map Editor? - 2d-games

I'am making simple platformer (C++, Tiled). But dont't understand how to implement mystery box. It must be an object or tile? If it better to be tile, then how animate tiles in tmx map.

Assuming you want to predetermine what will come out of the mystery box, it will be easier to use an object (can be a tile object) and not a plain tile on a tile layer. This is because you can associate a custom property with a tile object, to tell your game which item should come out.
Alternatively, you can use different tiles for each mystery box, but render them all the same in your game. This would allow you to quickly see where you put which item in the editor.
Using an object in your game rather than a plain tile should make it easier to animate it. But, you can always wait with creating such an object until the point where it is necessary.

Related

JavaFX creating interactive map

I have got a problem to set up the interactive map. I want to make the visual feedback as the mouse is moved over the map to indicate to users what areas they can click on (e.g. the mouse cursor might change when over a clickable
area/town or the area might be highlighted/glow).
How can I achieve this?
Your question is a little bit difficult to answer because you do not tell us how your map is drawn and what you already know about the geometry shown on the map. If you only have a raster image of your map, e.g. scanned from a paper map, then things are getting complicated.
For a similar task I first wrote a program to geo-reference the map and determine the outlines of the interesting areas in the form of polygons.
Then I used the polygons to draw the outlines on the map display. I added listeners to each polygon so that I am notified when the mouse enters or exits an area.

Google Maps API zoom without tiling

I'm using the Google Maps API to browse my own maps. The problem is, I only have one rather small resolution file, that I wanna display fully at level 0, which means it's not gonna get any more accurate when zooming. I still wanna be able to zoom though, by just enlarging the image. This would be useful for the markers and polygons I intend to draw on it, as they could be viewed in larger detail.
I could just create dummy tiles, that show no higher resolution than the original, but that seems like a roundabout solution that would do nothing but create more unnecessary server requests for the map files, as well as more traffic.
The problem seems to be the getTileUrl() function, as it is required. I can't think of a clever way to abuse it either, to only show different sections of the same map.
I know it already supports image enlarging, as you can observe the effect when you zoom in. The question is, if you could make that effect permanent somehow, and not make the image disappear if no new image is provided.
Suggestion:
Use the ImageMapType only to hide tiles at all(therefore let getTileUrl() simply return null)
For your own map don't use tiles, create a GroundOverlay instead.

Specific way of selecting a location on a google map

I've inherited a small project. The person before me created a native app for iPhone, implemented in objective-c, and my job is to remake it as a webapp with PhoneGap for iOS and Android.
In my predecessor's original implementation, part of the app has the functionality of allowing the user to drop a marker on a map to select a location. I found a comparable way of doing this, but the supervisor wants the exact way she'd done it, which I'm having a little trouble with. Let me describe:
In her native app, the map appears with a marker in the center of it. The user then slides the map around beneath the marker (which stays in place on the screen), until the marker is positioned over the spot they want. Then they hit a button marked "Select," and those coordinates are sent to the app for irrelevant other operations.
I'm trying to do the exact same thing with the google-maps javascript api and html/css, and I can't figure it out. Do any of you Gmaps pros have any ideas?
You may observe the center_changed-Event of the map. When it fires set the position of the marker to the new center of the map.
Another suggestion:
For a better effect instead of a marker you may use a custom control. You may insert a marker-image there so it will look like a marker. To place it in the center, push the control to
map.controls[google.maps.ControlPosition.RIGHT_CENTER]
(it will be vertically centered then) and apply the horizontal centering by adding a right-margin to the control

Adding tiles to map from multiple sources

I am working on a map for which I have multiple tiles sources that I want to be able to activate and deactivate using a menu on the side. Each tile set works independently when overlayed as an image map type, however I apparently can't show more than one of these at a time.
In any case, is it possible to display tiles from multiple tile url's? If not, then should I make some super overlay of tiles from all of my sources, and try to control which get loaded?
You can load and show as much tiles as you want to.
I can't tell you what went wrong in your approach without any code,
so I made an example: http://jsfiddle.net/doktormolle/NNJRn/
(Code for Overlay-Creation taken from the google-demo)

Creating an interactive map with CSS

Based on the design below, is it possible to create the map just using CSS? If so, how?
So as you can see, when you hover over a state the name will appear and change the color of the state. On clicking it will info below the map per state.
UPDATE 1:
Can it be done using absolute positioning, z-index and hover states on a button?
UPDATE 2:
With a slight tweak to the design, would it be possible to have a flat image for the map and plotting dot's on it for each state that would include a hover (using the same tab style as the image example)? Each dot being an image. Am I right in saying that the complication of the design is to highlight the right area when hovered? Therefore, just having a dot would solve it right?
I was interested in this too and found this example (USA) MAP if you look into the source code there is area for each state that look like <area onmouseover="show(this)" onmouseout="hide()" onclick="fform.tg.checked=false;togl()" shape="poly" coords="179,33,174,66,230,67,225,35,179,33,179,33" href="us-nd.html">. You can read more about and tags in W3C link. I think its the only way how to do this without flash or something... But it cant be done without a little JS. To get the coords, I would asume you just open your image in some editor that shows coords(gimp or something) and manually find them out...
No. If it had rectangular shapes yes but with a lot of work.
You really need javascript on this one.
You might want to try a Javascript mapping library - www.openlayers.org is the market leader (and free and open source).
You get your US state map in the right format (GML for example) then you can pretty much cut n paste from one of the openlayers examples. Hovering and clicking are handled by event functions. They can then do things like updating your info box below the map.
Note that if you want Alaska and Hawaii as in the picture and all you can find is a geographic state map, you might have to use a GIS to shift the features around. Quantum GIS is a free and open-source GIS that can do this for you. Help for that can be found on gis.stackexchange.com!
If you're willing to use javascript, jQuery more specifically, here is a nice plug-in/tutorial on how to do what it seems like you'd like to. http://playground.mobily.pl/jquery/mobily-map.html. It won't do the states exactly, but it will allow you to drop pins and such.
Update: This seems to be exactly what you're looking for: http://playground.mobily.pl/tutorials/building-an-interactive-map-with-raphael.html. It includes a rather indepth tutorial as well.
Here is another interactive US map I found myself: http://www.fla-shop.com/products/html5/united-states/us/ It is purely javascript with customizable popups.

Resources