Implement slots machine game animation - iphone

I am developing slots machine game in cocos2D. I want to implement the animation of the liver pulling. As in the image attached i want, that the user touches the liver and pull it downwards and the liver gives animation effect like it is being pulled in the way that it is coming outwards in the z direction to the half way downwards. How can i achieve this animation effect?

Make the lever a 3d model in blender(free) skin the model with the lever.
In blender animate the lever and then save the animation images frame by frame.
Make a list of png files for each frame(objective c does not like gif files)
Make an animation array and a UIImageView. Set that UIImageViews animationimages to the array.
When you want the user to simulate pulling the lever set the UIImageView to animating with a repeat count of 1.
Copy the animation backwards to have it go back into place if you want to.

I think the best answer has been given, if you want the game to have a 3d looking lever.
Another approach is to increase the size of the lever ball (SPIN) as you shrink the height of the handle. This would also give a similar look to the handle moving towards and away from the player.

Related

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.

Camera Rotation Animation

I have simulated a rotating cube filled with particles by moving the gravity vector rather than changing all of the geometry. I want to use the ParaView animation tools to rotate the camera to keep the gravity vector pointing down so it all looks right. When moving the camera (not animations) I would use the rotate 90 degrees tools.
How would I achieve this effect for an animation?
EDIT:
I have done it using a video editor as an extra step after ParaView, this is the effect I am going for: https://youtu.be/rym2fdKkPps
You cannot animate GUI button usage with animation. However you can animate camera position and orientation as finely as you want.
Try adding a camera track to the animation track of type "Interpolate Camera Location".
Add the two positions you want and set the time to be very close.

Cocos2d - Top down camera view with rotation

I'm trying to create a top down car game where the camera follows both the player and the player's rotation. I can get CCFollow to work easily, but I have had no success with CCCamera. I assume that I need the camera in order to make rotation follow the player (i.e. have the player facing up at all times) but I have had no luck on google.
Can anyone either provide a code snippet or a tutorial on how to create a rotation-following top down camera?
Cheers!
My suggestion: don't use the CCCamera.
Your game design requires the car to move over a track. In programming terms this is often much easier accomplished by keeping the car static, and instead moving the background underneath.
Assume your car is at the center of the screen. It's supposed to move from left to right. Instead of moving the car or the camera, move the background layer - just in reverse: move the background layer from right to left to make it seem like the car is moving from left to right.
The same is true for rotation. If you want the car to turn left, rotate the background in clockwise direction.
This is a lot easier and can be accomplished simply by changing the position and direction properties of the background layer. Note that you do not need to do this for each object in the background layer, it's sufficient to add all objects to the background layer in the appropriate positions and then just change the background layer properties. The layer's children will follow accordingly.

Scrolling a game environment in various directions

How does one create the game "area" for a scroller game?
How does one then put various obstacles with collision detection along this scrolled environment.
I want to try out a project which will allow the user to scroll to a certain direction in order to progress through the game.
How does one map the objects within the environment and then move what I guess is the "camera", the view of the environment.
Thanks
The trick is that there is no "area". The only bits that exist are what's under the camera (the view you currently see) and a small surrounding area giving you time to prepare more world in the direction you are moving..
Your world coordinates need to be defined as do the starting coordinates for the view. You use tiles to create the view - at its simplest that is 9 tiles, one you are currently "on" and one in each direction. If you look at the keyboard numberpad you are "on" the 5. If you move a little to the top right you are displaying parts of tiles 8, 9, 5 & 6. At that point you would create new tiles in case you move further. As you leave tile 5 you would probably release tiles 4, 1 & 2. Nine tiles may not be the optimal number of course.
If doing this with UIViews (probably not the high-performance choice) you are probably going to define one big view that can handle all the tiles and tile them onto the view (add and remove subviews), setting the large view's frame to define your camera position. As you move you change the frame to move your camera, when you need to shuffle tiles you move both the tiles and the frame to recenter giving room to move further within the coordinates of your view.
Collision detection is pretty simple since you define your own dimensions (the thing representing "you" in this world) and objects in your view have dimensions you can check against. CGRectIntersectsRect might be the simplest function to use but if you have irregularly-sized views it will get more complicated.
This answer about implementing a cyclic UIScrollView is a similar idea but it only handles scrolling on one direction.
This is a pretty common topic and if you google you will find a lot of sample code and tutorials around.
From the game logic side:
All your objects (lets call them gameobjects) should have a coordinate (x and y position) in your game world. You will keep all your gameobjects in a list. Your player object will be a gameobject too. Usually your "camera" position will be relative to your player objects position. I.e. the player will always be in the center of the screen. To determine the current "screen" position of your objects you will just subtract the camera position from your objects "world" position. Collision is usually made with simple rectangular overlap checks. You give all your objects a width and a height attribute and do your collision checks using x, y, width and height.
From the display side:
If you want to display many objects (i.e. Player, Enemies, Obstacles and so on) the best way to implement something like this is to use an OpenGL View. In this view you can display all Objects as Textures that are mapped to Polygons. You can use a library such as cocos2d which already has all of the code to achieve this easily.

magnifying moving images

im developing a 2d game on iphone in which i want to maginify the views on the screen to give the effect that the user is looking through the sniper whenever the user taps the screen..
i am required to show that the objects which the player wants to shoot should be moving...so im incremeting their position as well as increasing their size...
so i want this magnified image to show the updated positions of the moved objects at runtime to give the effect that the user is looking through the snpier...
scaling the images didnt help me cause it slowed my application a llot as the objects position is updated every 0.01 sec...
please help
Is it a 2d game, or are you using OpenGL ES? If the latter, you can always render your scene to a texture and use the hardware to scale that for you. That shouldn't slow down the game too much...
If 2d, it's always faster to scale one single image than a lot of individual objects, so here it also may be beneficial to render to an image first, and later scale and draw it on the screen.