Adding gravity effect to UI elements in OS X app? - objective-c

EDIT: To make the question clearer, I'll quote what Chris said in the comment, the question is "How can I do on OS X what UIKit Dynamics does on iOS?"
I want to add gravity effect to my UI elements in my OS X app, and I wonder if there are some best practices?
If I were developing an iOS app, I would turn to dynamic features introduced to UIKit in iOS7, but I couldn't find anything like that in AppKit. I've even tried to use Sprite Kit in a AppKit based app for its physics simulation, but I couldn't find a way to remove the annoying grey background in SKView even when I've set background to SKColor.clearColor().
So, I wonder if adding gravity is really that hard? Is there any best practices? I've found some apps, like Pixelmator, integrated some cool gravity features, so I guess that's possible? Can anyone help me out of here? Big thanks!
A small discussion: with the release of OS X 10.10, Apple is abandoning skeuomorphism, so is it still a good idea in design to add physics simulation in your app? Like the rope effect in Pixelmator app?

Related

Using Core Animation In SpriteKit

I've been prototyping some behaviour by using Keynote and I was wondering if it's possible to use Core Animation animations in a SpriteKit (OS X) app. I can't really find any info that suggests this is possible or not possible. Hopefully this is not a dumb question. If it is possible, what steps are necessary to set it up in a SpriteKit project to do something like an "anvil drop" animation on a sprite?

Would using cocos2d be easier for a drag and match game?

I am pretty new to making games, but I am pretty familiar with programing iOS. I am creating a shape matching game, so there would be an array of different shapes and the user would drag the shape to the correct corresponding shape if they get it right it would stay and if they get it wrong it would shoot back. Now my question is would that be easier using cocso2d or any game engine or would it be just as easy not using one, just using a touch event?
Since the game you are describing is not graphically intense - I would recommend using UIKit. Couple of reasons why I would use UIKit over cocos2d:
Interface builder / Storyboards are awesome. You can lay out your
screens and game elements on screen. (I know tools exist to do this
using cocos like CocosBuilder, but IMO they just don't compare to
working directly in XCode)
UIKit animations couldn't be easier and you can do some pretty powerful things with minimal code.
You have direct access elements such as UITableView, UICollectionView, UIScrollView, etc. There are cocos nodes that mimic these, but they don't match up in terms of response and behavior.
For more graphically intense games I would still use cocos2d hands down. Some scenarios when you would use it:
You have a large number of sprites with a large number of animations (opengl is fast)
You want to use opengl based effects like particles, lighting, etc.
You need a physics engine
You want to work off a prebuilt game engine (there are tons such as levelsvg, kobold2d, line starter kit, etc)
Hope this helps you.

Objective-C, Methods for animating gui

I've created many types of interfaces using the Cocoa API — some of them using documented basic animation techniques and others simply by experimenting (such as placing an animated .gif inside an NSImage class) — which had somewhat catastrophic consequences. The question I have is what is the correct or the most effective way to create an animated and dynamic GUI so that it runs optimally and properly?
The closest example I can think of that would use a similar type of animation would be something one might see done in flash on any number of interactive websites or interfaces. I'm sure flash can be used in a Cocoa app, although if there is a way to achieve a similar result without re-inventing the wheel, or having to use 3rd party SDKs, I would love to get some input. Keep in mind I'm not just thinking of animation for games, iOS, etc. — I'm most interested in an animated GUI for Mac OS X, and making it 'flow' as one might interact in it.
If u wish to add many graphics animations, then go for OpenGLES based xcode project for iOS. That helps u to reduce performance problem. You can render each of the frames in gif as 2D texture.
I would recommend that you take a look at Core Animation. It is Apples framework for hardware accelerated animations for both OS X and iOS. It's built for making animated GUIs.
You can animate the property changes for things like position, opacity, color, transforms etc and also animate gradients with CAGradientLayer and animate non-rectagunal shapes using CAShapeLayer and a lot of other things.
A good resource to get you started is the Core Animation Programming Guide.

Physics based animations for NON Game developer

I have worked of couple of iOS apps using Objective-C and XCode. Most of my apps are children's interactive books, completely written in Objective-C and all interactive animations are UIView based. In my next book, I would like to add some Physics based animations. What are my best options? I have never worked on Cocos2D or used any other physics based animations engines. I recently started reading about Chipmunk physics based animation engine. Should I be using Chipmunk along with Objective-C for achieving physics based animations or consider switching to Cocos2D? I am not considering game development at the moment. I would greatly appreciate your suggestions/advice.
Thanks,
Ramesh.
You can use Chipmunk without Cocos2d as you can see from its examples.
But i would recommend using Cocos2d along with Chipmunk. Cocos2d comes with a project template with Chipmunk, there are a lot of examples and all.
We did an interactive book with Cocos2d and Chipmunk with a lot of physics interactions and it works just great.

How do I move a sprite in Cocoa?

I'm working in Objective-C for a Mac cocoa application. It's a pretty simple question, but I can't find an answer. I just want to move a sprite across the screen, like in a Snake game. Do I need to use NSTimer or NSAnimation, and how would I use it?
Thanks
You could use Core Animation. It provides a unified way to move and animate visual elements on the screen.
If you plan to create a simple game, "Cocoa with Love" has a nice "Asteroid" example:
http://cocoawithlove.com/2009/02/asteroids-style-game-in-coreanimation.html
Another game-related Core Animation project is Apple's Geek Game Board:
http://developer.apple.com/library/mac/#samplecode/GeekGameBoard/Introduction/Intro.html
Well, actually it depends on how you imagined your application, there's a lot of way to make things move. If you do not need anything complex or particularly efficient you may just access and modify the NSView frame property. Otherwise you should consider use Core Animation or OpenGL.
Core Animation Programming Guide
OpenGL Programming Guide for MacOSX