How to save modified tilemap for level editor app - ios

I'm making a map editor app for iOS. I can't seem to find any information on how to save a modified tilemap, though. I'm using cocos2d-v3 for my framework.
Does someone have any ideas on how this is done?
Thanks

You could port the TMX writer of Kobold Kit: https://github.com/KoboldKit/KoboldKit/tree/master/KoboldKit/KoboldKitFree/Framework/TilemapModel/TMX
It actually originates from the KoboldTouch project for cocos2d-iphone, dependencies on the engine is minimal for the entire tilemap model. However there's no renderer for this model available for cocos2d (except in KoboldTouch), and cocos2d's own renderer does not retain all of the tmx information in memory, and certainly not in a way that makes it easy to write back.

You should be able to use the TMXGenerator class for this. It was written specifically to do that kind of thing. It's a little dated (pre v3, I haven't tried it with the new source), but it will get you most, if not all, of what you need.
https://github.com/slycrel/cocos2d-iphone-extensions/tree/develop/Extensions/TMXGenerator

Related

Is it possible to use Core Data in a document-based application?

I'm working on an iOS app that will need to save data onto files. I chose to go for a Document Based app, precisely an app based on a UIDocumentBrowserViewController so that I can easily save and load files from the system's Files app.
Since the data I need to save/load on a file is quite complex: big hierarchy of different objects, with meta-data, image files, etc. I'm wondering what is the best technology to use going forward.
I came across NSFileWrapperand its ability to save different files as one. And I could definitely use that. But I also saw UIManagedDocument and the ability to use Core Data in my project while maybe saving the content of the Core Data database (I know it's not quite a database, but you know what I mean) into a file that I could write somewhere in the File App.
Is this a behavior I can expect?
To reformulate: I'm wondering if I can read/write files through a UIDocumentBrowserViewController, with data described by a UIManagedDocument that works with Core Data.
Thank you in advance. 🙂
As you have discovered, UIManagedDocument is there for your kind of application. And it does feature methods to write and read additional content like the metadata or image files you have, within the document package.
That being said, I have never used UIManagedDocument, and have never seen it used by others. A quick search of GitHub finds only this one project with two contributors who wrote a wrapper around it in 2013. Also, there does not seem to be any sample code from Apple, and the remark in the the writeAdditionalContent(_:to:originalContentsURL:) documentation that Additional content is not supported on iCloud leaves me a little concerned, but maybe it's a good sign that the Core Data team knows where to draw the line.
I have used the macOS counterpart of UIManagedDocument, NSPersistentDocument. It is in a similar situation of not being used very much, but with many more known technical issues. So a few years ago I switched to BSManagedDocument, which purportedly mimics UIManagedDocument to support Core Data in all its modern glory. I have been happy with BSManagedDocument.
In summary, if I was in your situation, yes I would give UIManagedDocument a try. But don't be surprised if you need to use a DTS support incident or two during your development.

ios - Best way to create own level editor

I've created a core mechanic of my game and want to create a level editor for it. my game is not a tile-based one, so my needs are quite specific. Game is written using Swift and Cocos2d-swift, but i dont think i can figure something out with Sprite Builder.
What you can advice me? Can I for example create a level editor with c# and then use it from swift code?
And what data structure is the best?
I mean is it possible to serialize classes on desktop Swift application and then just load them on ios from file or I'll need to use json/xml?
It might be an old question but I ended up with using a .Net powered solution. I choosed as It has all controls that you need for creating a rich user interface and also, it has a lot of built-in and third party solutions for serializing levels in any way you want. And the c# syntax is very similar to the Swift one.
The only problem is that you might run windows to work with it.
My game in development also needed a non-tile level editor. A few months ago I took some time to make my choice.
Since my project still uses cocos2d 2.x, I don't use the whole new 3.x and SB system. After some investigation I found out that it would be too time consuming to adjust my whole project to the new system and adjusting SB to my needs, mainly because my game engine has been in development for quite some time and is close to finished. Further more, I couldn't find the right information to actually make it work for my game (it needed some odd level architecture I guess).
Finally, I didn't find any other good alternative so I decided to create my own level editor. In this way I had full control and I knew exactly how everything worked which was a huge advantage for me.
Right now my level editor has been finished for some time and works like a charm. I still think in my situation I made the right choice. Also because I learned a lot this way, building everything from the ground up. Having said that, for my next game I will probably go with the main stream and use SB from the start. Also for you I advice you to still check out SB and take some time for it before making an alternative choice...
I'll explain how I did mine. Disclaimer: it has some oddity's which only worked in my situation, but hopefully it helps a bit with choosing your own way to go, that's the goal I'm aiming at...
I used:
max/msp
Although it's developed to make music and audio based software, I used max/msp because it's very easy and fast for creating visual and interface based software as well.
More importend: I happened to be very experienced in it, which shortened the development time tremendously.
javascript
Inside the max/msp patch is a javascript file running. This file is like a bridge between the interface and the visual representation of the level being edited, and the database in which the level
is saved in. 70% of the editor development went into this file I think.
sqlite
All the data is written in a sqlite database. Again, this has been mainly the choice because it saved a great amount of development time in my case. I could have used xml files for instance, but my game was already using a sqlite database and because of this I felt comfortable using it, I had no experience in xml. Also all the code was already in place for a big part, which speeded up the whole proces a lot.
I'm very happy with the end result. It does everything I need, it's easy too use and since I made everything myself from the ground up I know exactly how every works.
Good luck with you choices.

Box2D in Objective-C

I am currently running Kobold 1.0.4 and cannot work out how to use Box2D using Objective-C, any help will be appreciated.
I have looked at the Box2d example project with kobold but it uses only c++ i need to do it in objective-c as i am not really confident playing with both.
Change extension of your source files from *.m to *.mm to be able to use c++ classes in them. It will allow you to create and manage box2d objects in your objective-c code
Box2D is written in C++ so one way or another there's no getting around it. Since Box2D's code does the heavy-lifting, the amount of C++ code needed to us it is quite small, you just need to get the boilerplate up for collision handlers and then the code you fill it with can be as objective-C as you want.
If you want something that helps get geometry into your app, PhysicsEditor is a good tool and they have a plist exporter and provide an objective-C class for loading the data. It takes care of a lot of boilerplate, and if you want to do collision geometry for anything interesting it's very helpful.

How to write a code to read .fla file?

I was wondering so long that how can people analyze the trait of each file extension (of course open it in notepad is not readable)
For example, I want to write a program that can read everything from .fla file like timeline, movie clips, position of each MCs or all the motion tween values. And get the image embeded in it. (I'm planning to use flash as IDE for another project.)
(The reason that I tried to read proprietary format is I want to utilize their awesome editor. What I actually want to do is, I want to make an iOS game with cocos2d. There is a code to move things around in cocos2d but there is no decent editor. So I'd like to use Flash as an editor, then convert the motion to objective-C cocos2D code by reading the .fla file.)
If you would like to be able to import timeline animation from flash into cocos2d, this tool might help. More information in this thread.
The grapefrukt-exporter might also help as it can export keyframe data, and various other formats for animation.
Instead of creating the tool yourself, it might be much easier (and time saving) to use one of these and integrate it into your workflow :)
Finally, if none of the above works, how about just exporting the flash animation as an animated GIF or a movie file?
Im assuming you want to write a decompiler, this is possible and there are several available on the internet, price varies.
It is not possible for flash to achieve this, Most programs, software are built on a native language such as C, Native meaning it can independly run in its own with out initially setting up an invironment to support it.
Flash is not independent enough to be available to have this much power.
Try looking at c++ or C# as this would be possible, also these languages are a lot more powerful.

Can the UDK be used for non-game projects?

This is a pretty basic question. I am wondering if the Unreal Development Kit can be used for something other than games, specifically a light show simulator and editor. The site says:
Unreal Engine 3 has been used by game developers, researchers, television studios, machinima directors, artists and students. If you have an idea that needs to be brought to life in a game engine, UDK is for you.
But I have the feeling that it is more game oriented. For my hobby project, I would like to be able to create light show simulations with rotating/moving lasers/lights of changing color, synchronized to sound/music. I would also like to develop an GUI editor for this, preferably in C#, but if it's not possible to access the rendering functionality of the engine from C#, then C++/Qt should suffice. The editor would be used to design the simulation, which would then be rendered/played out in real time.
I guess my base, general question is: can the Unreal Development Kit be used for something like this, not necessarily game related? Or should I go with my original option of Ogre3D, which just focuses on rendering and 3D graphics as far as I know.
EDIT: Just saw this page which again mentions:
Can I create any kind of game with UDK?
Absolutely. UDK is the perfect solution for any kind of virtual world you wish to create, from racing games to simulations.
So my question is now simply: Would I be able to access the renderer or other functionality of my resulting code to integrate it into an editor for my simulator? I guess a simpler, more relatable analogy would be, if I wrote a game, would I be able to write my own level/character/etc. editor for it? And how would I do so? Yes, I know that the UDK comes with editors already, but I mean if I want to make my own.
Thanks! I appreciate any answers :)
The UDK only permits you to play with script (Unreal Script) and not with native code (c++). So more complicated projects or integrations are very difficult without the full c++ source code. But if you will re-use the editor (UnrealED) for your project and make you simulation based upon unreal you can do it.
I'm pretty well oriented in what Unreal Engine can do, and answer to your question is yes and no ;)
Yes, you can create your own actors that will be rotating/moving and emitting light. But won't be able to create your own custom editor around UE's rendered. Frankly I don't see why you would need one - Unreal Editor has all the tools needed to design and execute light show simulation (and much more) - all you need to do is to get familiar with those tools.
One thing you could do in external editor (except, of course, for textures, sounds, models, etc) is create some custom setup in saved to text files, and later read in those files in unreal script - it allows it.
"I guess a simpler, more relatable analogy would be, if I wrote a game, would I be able to write my own level/character/etc. editor for it?"
Yes, you can make your own characters and maps. You shouldn't have any need to make your own editor though, the given editor should be enough.
Although you might not have access to the C++ source code, there is a lot that can be done using Unrealscript. Check out all the entries to the Make Something Unreal contest, they were all done using tools available in the UDK.

Resources