I want to be able to load a list or an array of tiles and displayed them on a map.
Cocos2D offers a possibility to load tiles on a map. But for my case, I have to load just a specific part/range of tiles (which I define) and this changes dynamically during the run time. I never want to load the whole map at once. Is this possibile? Maybe an alternative to Cocos2D on iOS? The map details come from a server. It should be done in a quite large multiplayer environment, that's why each player/client should only load his relevant parts of the map.
You can definitely do this, and there are many different ways. For example, swapping scenes or layers during run time, with different tile maps on them, or by creating tile maps your own way with a custom set of methods using CCSprite (for example, it is common to create your own parallax scene instead of using the built-in Parallax scene methods in Cocos2d, and you could do the same with tile maps, if desired). The options are really limited only by creativity.
Related
I'm making a tile-based adventure game in SpriteKit and I'm trying to figure out a good way to store my maps. A typical map might have 100x100 tile dimensions. Currently I have a very small 8x16 map which I'm storing in a 2x2 Swift array. However, making maps in arrays seems like bad practice as the map size increases. What would be the best way to store this map data?
There is nothing wrong with using 2 dimensional arrays, in fact, if you use arrays, then you can save them into plists to make things easier for you.
I would personally write my own class that wraps around the 2D array so that it suits my needs (E.G. if I am adding a column, it will add the column to every row)
I don't know if this suits your need but you could use the editor Tiled which offers you a visual way to create your maps.
Maps are saved as .tmx file (basically an XML file). Then you can import them in your game using one of the listed solutions. You can event create your own solution pretty easily (second answer in the given link)
This solution makes creating/modifying maps easier, but you have to use an external software.
I have a SpriteKit game that accesses the sprite atlas images without issue.
However, in some of my menus I am using standard iOS UI components like table views and collection views. For those screens I lay out everything on a standard UIView controller.
However, on these screens I am not able to access the images unless I add those images to a separate folder which is not ideal.
How can I access them from the texture atlas? Thanks
You can't. Add these images separately, whether you also need to add these images to a Sprite Kit atlas depends on whether the game's performance suffers if you don't. There's currently no practical way to extract individual images from a SKTextureAtlas.
I am interested in roughly how megatextures are/could be implemented on iOS.
In particular I am making a 2D platformer with a large (non-tiled) background and I would like to have one (precalculated, unreasonably large) image that is mapped to the background. One option I have gone with is to chop the precalulated image into tiles, and load/unload in the background.
I am however curious about megatextures. It would be far more convenient to map these all to one surface. Are megatextures simply another way of phrasing what I am doing right now, or is something more cunning going on. Is there one superlarge texture on the graphics card with multiple gltexsubimage2d calls going on?
Megatexture is a well-developed and advanced implementation of clip-mapping technique: http://en.wikipedia.org/wiki/Clipmap
So yes, basically it is a continuous background loading of content to be displayed and unloading of currently unused content.
I'd like to provide custom navigation maps in my iOS 6 application. I've tried adding overlay views that shows these custom maps in MKMapView and it didn't work well because it needs a higher zoom level than what Apple's component can provide (the desired zoom level is about 10 screen points per meter in the map).
The question is, is subclassing MKMapView a good way to approach to this? The primary reason is I'd like to take advantage of MKMapView's coordinate conversion functions:
convertCoordinate:toPointToView:
convertPoint:toCoordinateFromView:
convertRegion:toRectToView:
convertRect:toRegionFromView:
Those functions makes it easy to convert screen points to world coordinates (latitude/longitude) and vice-versa.
Thanks in advance!
I don't think you are going to have much luck with subclassing MKMapView. There is a lot going on behind the scenes related to tile loading that you cannot access.
I would guess you would be better served using something along the lines of the MapBox iOS SDK or another similar map engine.
It allows you to specify your own tile sources and has plenty of examples to show you how it is done. It also had functions, like map kit, to handle converting values to and from lat/lon.
I am making a game where bullets are involved. Its a machine gun, so there will be more than one bullet on the screen at the same time. How to I write the code for the properties and actions of one bullet and apply that to all of them, like multiple instances of the one bullet?
The key point to making a game is the concept of sprite, i.e., a light-weight object that has a graphical representation and that you can move around (managing collisions, etc).
You could try to implement sprites on top of CALayers, using Core Animation, or you might decide to use a game framework like Cocos2D.
For the first approach have a look at this short tutorial. This could also help you if you want to implement your sprites using UIImageViews, although you have to keep in mind that CALayer are light-weight, UIView are not, so if you plan to have many of them that could make a difference.
As to the question of replicating the bullet, basically the key suggestion would be using some form of caching, so that you do not end up replicating the same image in memory multiple times. A very basic caching mechanism is available with the UIImage class if you use the convenience constructor imageNamed.
Again, if you plan to make a full fledged game with a good performance (say 40-60 fps), the best suggestion is using Cocos2D, which will offer you all the power of Open GL graphics wrapped in a simple interface.
Have you tried subclassing UIImageView? That way you can have a function createBullet that creates a subclassed UIImageView and adds it to the screen, and in the subclass it can contain functions and properties for animating etc...