The most effective way of sprite(frame) animation in Monotouch - ios

I would like to know the best(high performance / FPS) way of doing sprite (frame) animations in a MonoTouch project.
I'm doing this very effectively in Android by decoding whole sprite image, clip it at desired sizes and display frames at desired pace.
So, what's the most effective way of doing this in Monotouch, in terms of FPS.
Thanks in advance.

Have you looked at using MonoGame?
The SpriteBatch class works well for us. It is OpenTK/OpenGL underneath, so you could repurpose it for your needs if you don't want to use full MonoGame.

It depends on what are the demands that you have for your sprites.
If your requirements fall in the scope of what CoreAnimation can do, you can just your image into a UIView and use CoreAnimation to animate the view.
If you need more control, MonoGame provides a more comprehensive set of primitives for dealing with sprites.

Related

How to animate sprite with fluent animation (change in form) in swift?

I'm trying to work on the graphical aspect of a game I'm designing in Xcode using sprite kit, and I was wondering if anyone knows how the main character sprites in games like Leo's Fortune and Badland are animated when touched (they fluff up and morph very fluently). How could this be accomplished and what compatible file type could execute this fluent animation? Is .flv compatible with Xcode? I would rather not change the texture in a keyframe sort of way with a .png because that would require a lot of textures at a high texture switching rate.
Any advice on this matter would be greatly appreciated
Thanks

When to switch from drawRect: to OpenGL/Metal?

I've been building a 2D game and I've been drawing the playing area inside of a UIViewsubclass where I override drawRect: and draw the game with a lot of UIBezierPath* objects. I'm not very experienced on iOS and I've been wondering if this is the right way to do it.
So I guess my question is How much is enough? When should I stop using UIBezierPathand start using OpenGL or Metal? Can I use these to draw inside an UIViewor they take total control of the screen?
There is no answer on when you should stop using UIBezierPath. You need to ask yourself in the beginning on what tool will you need to use to achieve what you need for your application to work the way you want it to. The core graphics procedure which you use is very simple comparing to openGL or such but the performance is not at its best and mostly you are very limited on what you can even achieve in drawing. In general you should use as easy procedure as possible as long as it works out for you.
OpenGL and Metal are bond to the view and do not take control of your whole window (the screen in iOS). Also you can still add subviews to those views without breaking any drawing or functionality so for instance even a full screen view openGL application can have a simple UIButton to for instance pause the game or make your main character take that big sword and slay the dragon saving the princess.

Efficient way to draw many shapes on UIScrollView, scrollable and zoomable

I’m working on various iOS apps and I need an interface with the following capabilities:
I have a scrollview (covering most of the screen) which is scrollable both directions
This scrollable view contains a lot of rectangles. These rectangles are intractable. User can modify them, move them around, create and delete. So ideally they would be all CALayers or UIViews.
The problem is because there could be 100s or 1000s of those displayed at once, CALayers or UIViews may not be very efficient.
The scrollview could be 10-20 times bigger than the screen size itself. And fully covered with these shapes. So when the user scrolls it shouldn’t see any flickers or shapes appearing after the scrolling is done. e.g. If I use CATiledLayer and user scrolls, you can see things drawn after scrolling is done.
Smooth zooming. Zooming out is particularly challenging, because the shapes would need to be drawn on parts of the view which are going to become visible. Also, ideally I’d rather not use something like CGAffineTransform to perform scaling, I like to have a pixel accurate scaling.
I’ve tried various things, but I can’t seem to be able to get decent frame rates even on iPhone 6. Even tried drawing every frame, but it’s too expensive Core Graphics to handle it. Is there code examples someone trying to do a similar thing or an open source library? I’m trying not to use OpenGL, I feel like it’s an overkill, but I will try it if I have to. FYI, I have no experience in OpenGL yet.
Procreate for iPad does what I’m trying to do perfectly, it’s super responsive and zooming is pixel accurate. I know they use OpenGL and I’m not making drawing apps. The reason I mention it is because it shows what I’m trying to do is possible.
I think you need to move from UIKit to some 2d or 3d engines:
Cocos2D
Sparrow
Unity
OOlong

iOS Heavy image switching

I'm developing a app that will showcase products. One of the features of this app is that you will be able to "rotate" the product, using your finger/Pan-Gesture.
I was thinking in implementing this by taking photos of the product from different angles so when you "drag" the image, all I would have to do is switch the image according. If you drag a little, i switch only 1 image... if you drag a lot, i will switch them in cadence making it look like a movie... but i have a concerns and a probable solution:
Is this "performatic"? Since its a art/museum product showcase, the photos will be quite large in size/definition, and loading/switching when "dragged a lot" might be a problem because it would cause "flickering"... And the solution would be: instead of loading pic-by-pic i would put them all inside one massive sheet, and work through them as if they were a sprite...
Is that a good ideia? Or should I stick with the pic-by-pic rotation?
Edit 1: There`s a complicator: the user will be able to zoom in/out and to rotate the product in any axis (X, Y and Z)...
My personal opinion, I don't think this will work the way you hope or the performance and/or aesthetics will not be what you want.
1) Taking individuals shots that you then try to keyframe to based on touch events won't work well because you will have inevitable inconsistencies in 'framing' the shots such that the playback won't be smooth
2) The best way to do this, I suspect, will be to shoot it with video and shoot it with some sort of rig that allows you to keep the camera fixed while rotating the object
3) I'm pretty sure this is how most 'professional' grade product carousel type presentations work
4) Even then you will have more image frames than you need -- not sure whether you plan to embed the images files in app or download on demand -- but that is also a consideration in terms of how much downsampling you'll need to do to reduce frames/file size
Suggestion
Look at shooting these as video (somewhat like described above) and downsampling and removing excess frames using a video editor. Then you could use AVFoundation for playback and use your gestures to 'scrub' into the video frames. I worked on something like this for HTML playback at a large company and I can assure you it was done with video.
Alternatively, if video won't work for you. Your sprite sheet solution might work (consider using SpriteKit). But then keep in mind what I said about trying to keyframe one off camera shots together -- it just won't work well. Maybe a compromise would be to shoot static images but do so by fixing the camera and rotating the objects at very specific increments. That could work as well I suppose but you will need to be very careful about light and other atmospehrics. It doesn't take much variation at all to be detectable to the human eye causing the whole presentation to seem strange. Good luck.
A coder from my company did something like this before using 360 images of an object and it worked just great but it didn't have zoom. Maybe you could add zoom by adding a pinch gesture recognizer and placing the image view into a scroll view to zoom in on the static image.
This scenario sounds like what you really need is a simple 3D model loader library or write it in OpenGL yourself. But this pan and zoom behavior is really basic when you make that jump to 3D so it should be easy to find lots of examples.
All depends on your situation and time constraints :)

How do i implement effects in cocos2d?

What is the best and most efficient way to add effects to a game built with cocos2d?
I mean effects like an explosion.
Are they just animation / sprits?
If not, then what should i receive from the designer?
You can run cocos2d project which comes with library and in the top left drop down list you can choose Particle System Test and build it. So you will able to see all basic particle effects cocos2d has.
Also there is a nice application ParticleDesigner, where you can make your nice looking particles and generate a file to add to cocos2d project, it also has a lot of samples, so it would be good for you to download it and see.
And cocos2d supports animations as well, so you can make animations from frames, but of course in the case of explosions particles would look much better
I would take a look at CCParticleSystem and or CCParticleSystemQuad. You or your designer can use tools like ParticleDesigner to create great looking particle effects.

Resources