Box2D in Objective-C - ios

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.

Related

Giving or changing the implementation of method at runtime in iOS

Recently i caught with the a thought of changing the implementation of method after deployment
When i googled about objective c runtime and all, came to know about method swizzling methodExchangeImplementations etc.
I know that it could be possible by https://rollout.io/
But my thought is how to do Hot Patching by myself for simple things.
my idea is injecting the code using webservice call.
Webservice should give a replacement for particular method.
That string has to be converted to executable code
What i want to know is ...
How to inject the code in existing method of enterprise application.
For ex:
Consider this method in objective c
-(void)fetchTheResult{
// some code lines
}
After deployment i would like to change the method implementation to
-(void)fetchTheresult{
NSLog(#"test log");
//some Code lines
//some more lines
}
Please guide me the way to achieve this
This is a big question and you've some research to do to figure out an answer. Here as some things you can look into:
First you've referenced Rollout, you could follow the same idea and send your update as JavaScript. You'll need to study how to call JavaScript, swizzle methods, and probably dynamically add methods - more on that in a moment.
An alternative you can investigate is dynamic library loading - you can open, and call code in, a library which your app loads at runtime. So you could look at sending your update as a library. You'll still need to do method swizzling and probably dynamically add methods...
As well as method swizzling you may find you need to dynamically add methods - e.g. so you have something to swap the existing implementation to. A good place to find out how to do that is Mike Ash's writings on KVO - go DuckDuckGo (or Google)
HTH
It is not as easy as you think, at least in Objective C and other similar compiled languages. This kind of runtime changes to the code is only possible in interpreted languages like Javascript.
The basic problem is, the apps are not allowed to change the executable files themselves. The apps on iOS and Android run in a sandboxed environment, and thus have access to limited disk locations only.
Also, after compiling the code, the code does not know where the part of code is converted and stored in machine language. You have to understand the basics of compilers to understand this. There are heavy optimisations happening to your code during this process.

How to save modified tilemap for level editor app

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

Using Matlab capabilities in xcode project

I am familiar with Matlab and would like to use what I know to add the functionality I am looking for in my iOS application. The title really says it all, I would like my app to be able to use the mathematics capabilities that matlab provides like integrals, derivatives, cross products, etc. not any graphing or any of that but just basic equation solving things. Is there a way to add this functionality to it while keeping my application agile. I have heard of the matlab coder that allow code to be switched from matlab to c or c++ that could be used for an Xcode project. If this is the best solution, is that a very difficult coder to work with? This is my first application, I have literally been working with Xcode and objective-c for a few weeks but I have the basic framework of my application good to go. I need this to add the real functionality to it and make it very useable. Please go easy on me if any of my questions seem obvious, I'm a nube, I really appreciate your answers.
Josh
As you mentioned, MATLAB Coder can generate C code from your MATLAB function. The header (.h) and source (.c) files can be plugged into your XCode project. The key part of the work is to decide what the input and output of the function should be and how to interface the rest of the XCode project with the Coder-generated function. Also, existing MATLAB code may not be completely compatible with the Coder, so that some modifications to your MATLAB code may be necessary. The Coder has interactive processes that guide you through this process.
If you haven't done so yet, you should start by looking at some examples of MATLAB Coder provided by MathWorks, e.g.,
http://www.mathworks.com/help/coder/examples/c-code-generation-for-a-matlab-kalman-filtering-algorithm.html?prodcode=ME&language=en

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.

Is there a MonoTouch wrapper for UIImage-DSP library?

I'm searching for a MonoTouch wrapper (or a complete port) of this library:
https://github.com/gdawg/uiimage-dsp
UIImage Image Processing extensions using the vDSP/Accelerate framework.
Fast Image Blur/Sharpen/Emboss/Matrix operations for UIImage.
REQUIRES IOS 4.0 and The Accelerate framework.
Thanks in advance.
You won't find bindings for it - at least not in it's actual form. Quote from the URL you supplied:
Copy the UIImage+DSP.h and UIImage+DSP.m classes into your project
So it's not yet a library. Someone could maybe it one from the code but, until then, you won't find bindings for it.
As for a complete port the next quote
these aren't quite as fast
makes it sounds like translating the code to C# (lots of array, bounds checks... even if they could be eliminated with unsafe code) is not the best option. I suggest you keep looking at another (OpenGL-ES maybe?) solution - like your previous question here: How to do a motion blur effect on an UIImageView in Monotouch?
Maybe even add a bounty once you get enough reputation points :-)
I wrote a native port of the blur and tint UIImage categories from WWDC for Monotouch.
https://github.com/lipka/MonoTouch.UIImageEffects
It uses the Accelerate.framework - you can possible extend on it if it doesn't exactly suit your needs.

Resources