Physics engine or not for making a Pendulum in iOS? - ios

I'm trying to replicate the pendulum effect as seen in the old game "Gold miner", if you ever played it before. Do I need to use a physics engine for that, or not? I heard that Box2D is preferred over Chipmunk when it comes to ropes, but do I really have to join two objects together with a rope to accomplish this pendulum effect? I'd love to do it without a physics engine, but if I have to use one I think I would pref chipmunk as it comes with Cocos2d v3. (In short, whats the best way of making a pendulum that swings forever and can be lowered and raised)
Im' a complete n00b when it comes to physics engines, never used one before, only made non-games apps before :/ Any help is very appreciated =)

You mean the grappling hook in that game? That's absolutely not physics, or at least can be done easily without a physics engine. At best you may want to use the physicss engine's raycast collision detection methods (if any).

Related

How to move "obstacle" objects. Corona SDK Physics Box2D. Physics Update?

I'm trying to understand the proper way to move "obstacle" objects in corona/box2d. I want to know how to write my code so that the movement is deterministic and in-step with the physics engine. Is this possible?
I'm familiar with Unity which has a physics update (FixedUpdate). Where you can add a bit of code to execute on every physics step. This keeps the physics deterministic, frame and system time independent.
For example, in my game I want to do things like: Make a platform that moves back and forth, make an object that scales up and down in size. I would still like the physics to work properly and allow the ball in my game to bounce off of these for example. Depending on the case, I imagine that I should use either kinematic or dynamic bodies.
I've searched around and the way to periodically manipulate these objects is to use:
timer.performWithDelay. But this has an issue mentioned in the docs "Timers run on system time. If the app is suspended, running timers will not be automatically paused"
Listening to an enterFrame event. But this has a similar issue, if the frame rate drops then the object won't be moved enough. We can use delta time to deal with this, but this has determinism issues (moving an object too much on a lag spike).
transition.to. I'm guessing this is implemented with timer.performWithDelay and has the same issues.
I don't think that any of these will behave deterministic. Any suggestions? Thanks for the help.
You should really use:
object:setLinearVelocity(xVelocity, yVelocity)
or
object:applyForce(xForce, yForce)
instead of transition.to.

SpriteKit: Should I pan the camera or move the background?

When building a game with SpriteKit, with a platformer game (like Doodle Jump for example), is it preferable to move the camera up, or the background nodes down ?
What is the standard practice in other frameworks ?
MOVE THE CAMERA!!!
One of the weirdest things about 2D game engines is that it often takes them a series of versions to get a camera.
They should be born with them.
SpriteKit was no different, it took forever to get a camera.
Now that it has one, never ever think of not using it.
Will make your life a million times simpler.
I can think of no exceptions, but look forward to being proven wrong.
move background was HOTFIX until proper cam support added.
use the cam. its easy and fun. no reason to not imo.

iOS + Cocos2D: Simple Colission/Bounce (do I need box2d/chipmunk?)

So I am writing a simple game and need to do collision detection. Basically balls are going to bounce off each other as well as walls.
Do you think chipmunk/box2d would be overkill for this? Or can I just implement the algorithm myself?
I'm a huge fan of Box2d so I'd recommend using that. Your simple game may start of simple but if you ever want to do more then you are all setup. Also, once you implement it and get the basics down you'll be amazed at how simple it is. If you decide to go with Chipmunk though, I've heard a lot of good things about Space Manager (http://code.google.com/p/chipmunk-spacemanager/) as far as being really easy to implement, but I have not used it myself.
Check out: http://www.raywenderlich.com/457/intro-to-box2d-with-cocos2d-tutorial-bouncing-balls
for a great tutorial
Detecting collisions of the balls will be easy. Making them bounce realistically is the difficult part. The more realism you want/need, the better off you will be using a physics engine.

iOS - Cocos2d, Box2d or Chipmunk

I have to develop an app which has on screen 10 balls. When user shake the phone a sound will play and the ball have to move around the screen colliding each others without go out of bounds. I think i have to use cocos2d, box2d or chipmunk, but i don't know how can i do a thing like that. If someone have a tutorial, or some code it will be very appreciated.
I found another method that could be useful, it's CGRectIntersectRect(obj1.frame, obj2.frame)
but i think it isn't the correct way for my problem, is it right?
Thanks
Box2d or Chipmunk are supposed to take care of the collisions, so you don't have to use functions like CGRectIntersectRect to handle these kinds of events.
Start with some cocos2d tutorials to see how to display sprites on the screen and after that see some tutorials for your physics system of choice.
Box2d and Chipmunk are physics engines that come WITH cocos2d, cocos2d is the graphics engine.
I suggest you go for Box2d as it not only provides collision detections (including with circle body shapes for your case) but also lets you handle all the physics etc. I've never used Chipmunk.
There is a short Objective-Chipmunk tutorial that does most of what you are looking for already:
http://chipmunk-physics.net/tutorials/SimpleObjectiveChipmunk/

How should I do this (Game)?

Right now I have coded about 80% of my game and the remaining 20% is the actual game part of it. I need to know how I should go upon actually making the game part.
Pretty much it will be somewhat similar to Doodle Jump. There will be gravity, the accelerometer, and a spawn system for platforms. I need to know if I should use UIKit or Cocos2D for this.
I know I can do gravity and use the accelerometer easily using UIKit but I am worried about the platform part. My 'Doodle Jump character' is not a regular square or rectangle so should I just crop it as best I can? The reason I am worried is because say the character falls on a platform, so his body could be a little off since CGRectIntersectsRect does not have pixel collision detection, so do you think it is fine the way it is?
If you need more info or aren't sure what I am trying to do, just let me know. In the end I just need to know if I should use Cocos2D or UIKit.
Please let me know your thoughts.
Thanks!
My answer would be that, while you may be able to develop the game in UIKit, my suspiction is that it will be better in the long run to do it in Cocos2D. Not only will you have tools which are better for doing stuff like collision detection, you can also use a Physics Engine to handle the gravity and things like that. Basically, Cocos2d was made to do exactly the kinds of things you want to do, and UIKit wasn't...it was made for user interfaces.
Still, the collision detection you do will, mostly likely, not need to be down the level of individual pixels. One rectangle might be enough, or perhaps you can use several to get more accuracy. So can you pull it off in UIKit...maybe, but I bet your game will turnout better overall if you use Cocos2d.

Resources