Animate a Stick Figure with Cocos2d, images vs. drawing? - iphone

I saw this question on a Cocos2d forum, and I would really like to see the answer, I'm assuming its more likely to get answered here:
I was wondering what would be the best method to go about animating a stick figure running, walking, etc.
I need to have a wide and flexible range of motion, so prefer to actually animate multiple lines rather than create premade images and flip through them.
Would I use rotation or use trigonometry to figure coordinates from the angle of the moving extremities?
Any advice, direction or code snippets would be really appreciated!

You could set your own anchor points for each sprite to animate with the rotation- that way you could rotate an arm from the end of the arm just by using rotate instead of doing a lot of complicated math. Setting the anchor point also allows you to translate the sprite along that point instead of its center. Anchorpoint tutorial.
However, I think that it might be easier just to create a lot of images of the stick figure doing all of the actions. I think that n game does this and their character has a lot of animations.

Related

Is it possible to animate anything with natural way in Unity or smt else?

I m wondering that if is it possible to animate anything along the rules of physics.
I mean, i have a cube, and two legs attached to that cube. I want to just animate that legs one after each other, but unity or other software will force its animation system to behave to my animated legs to make my cube walk. I wont change positions for my body(cube) but legs will do that.
demonstration:
https://streamable.com/dda610
Yes, this animation type is called procedural animation. You base your animations dynamically based on physics.
https://en.wikipedia.org/wiki/Procedural_animation
good video:
https://www.youtube.com/watch?v=LNidsMesxSE
tutorial:
https://www.youtube.com/watch?v=9Wh6fzSl_u8
Physically based animation is a complex task. You can use the timeline to animate legs but they won't work too well physically. You probably want to use code to keep the body a fixed height above the surface and use the timeline editor to animate the legs. Or perhaps keep the body at the same height and use 'inverse kinematics' to move the legs in a more realistic fashion. Neither of these options will be very quick for you to start using really effectively if you have very little experience with unity or with code but knowing what to look up is half the battle of learning.

Unity - How to disable animation interpolation / animation curves?

I'm trying to animate a hierarchy of 2D sprites (essentially body parts) by explicitly setting sprite positions at various key frames throughout a given animation clip. Unfortunately, Unity is implicitly changing all of the sprite positions using interpolation between key frames. This causes the sprites to look like they're sliding around rather than immediately transitioning into their correct positions.
So far I've come up with 2 rather poor solutions:
I could potentially create separate animation clips for each combination of sprite positions and transition
between them using mecanim parameters or in
code, but this seems tedious at best and inefficient at worst.
I could add more keyframes (either in the animator tab or in the
curves screen) that maintain each sprite position until just before
they need to be updated. This is a slightly better option but also
extremely tedious.
Is there any way to tell Unity to disable animation interpolation at least as far as positions are concerned? Thanks.
In the current version of Unity (2019.3), go to curves view, right click a keyframe node and select Left Tangent -> Constant. You may want to use Right Tangent depending on the use case. That should give you the instant change you're looking for.
Have you checked Brackeys video of animating 2D in Unity? Maybe it can help you :)
The following link is his video on how to animate 2D sprites.
https://www.youtube.com/watch?v=whzomFgjT50
Alright, I've come to the unfortunate conclusion that Unity forces you to use curves when dealing with animation keyframes and that you need to add an extra set of keyframes for abrupt shifts in animation.

Concept behind Arcs Puzzle

Here video link for the Arc puzzle
Can anyone please tell me what concept is used behind this game. I have just started learning Iphone and this game is pretty cool. First I thought it might be using core animation and core graphics. But seeing the movement of the objects it looks much more complicated.
Can anyone tell me what kind of approach do one need to build something like this.
That could very well be Core Animation. You could do the whole thing with CAShapeLayer objects. The code would probably be simplest if each "track/sector" of the arcs puzzle was a separate shape layer.
With a shape layer, if you change the path that defines the shape, as long as the old path and the new path have the same number and type of control points, the change can be animated. Thus, you could animate rotating one of the tracks, (rotation transform around the center point for all track/sector shapes in the track) or animate sliding a track/sector in or out.

iOS - rotating a sphere and responding to touch

I've been tasked with creating a sphere that can be rotated by touch (or animated) along one axis, like a regular globe. I should also be able to draw animated lines on this sphere (eg. draw a line between Sydney and New York). I usually do all my animations in 2D, typically using core animation as I've never really had a need to do anything else. I have a feeling that this sort of problem though requires me to jump into OpenGL.
My question is whether it would be possible to achieve this using core animation (time is of the essence), or if I do need to quickly learn OpenGL. If so, is this a fairly simple problem to solve? I'm a pretty good programmer, but I have no OpenGL experience. Would a capable programmer be able to do this in say 2 weeks?
As a further question, supposing I do use OpenGL, if I then need to do other things in the project (eg. show different screens, or show screens over the top of the sphere), am I able to use UIKit or does the entire project need to be in OpenGL?
Core Animation is for animating views, and basically a 2D animation layer - so it's a no-go for the 3D rotating sphere.
Drawing a textured sphere is rather easy, see this sample
Mixing GL and regular UIView's is not a problem. You can overlay regular controls over the GL view.

Iphone OpengGL ES: detecting clicks on a primitive

I have created a 3d environment full of 3D cubes, does anyone have any idea how you would detect a touch on one of these Cubes. I thinking if I could get the cubes screen position (coords start from bottom left) then it would be pretty easy
UPDATE:
I added the function -(CGPoint)getScreenCoorOfPoint:(IMPoint3D)_point3D which seems to give me my items position in the world but the bit I am now stuck on is:
I have objects that have a position
I have my position in the world (gluLookAt eye[0], eye[1], eye[2])
and then I have where I tapped on the screen
How do I join all this up, its the last thing in my way to archiving greatness!!!!
Look up OpenGL picking on Google. There are two main methods to accomplish this, I recommend you use the second one described at OpenGL.org as it does not involve rendering anything offscreen:
[…] involves shooting a pick ray through the mouse location and testing for intersections with the currently displayed objects. OpenGL doesn't test for ray intersections, but you'll need to interact with OpenGL to generate the pick ray.
Also see this question for some discussion on the matter:
Screen-to-World coordinate conversion in OpenGLES an easy task?