Get Updates By E-mail 

animation

Beginners Tutorial: Basic Touch And Animation

  •  
  •  
  •  
  •  
  •  

Many put off using basic core animation and uikit as a way of making games almost by default.

The fact of the matter is that core animation is probably the easiest way to create a game on iOS. With a more complicated game you will run into performance issues,  but for many games it works just fine, and you can lay things out in interface builder.. perfect for someone just starting out since the concepts will work across different UIKit interface components.

I found this great tutorial for beginners from Tudor Munteanu that is worth checking out covering basic touch and animation which you can find here:
Learning About Touch Events And Basic Game Animation

There is a small error in the code, and just in case it hasn’t been fixed yet you need to change the lines:

UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom]
initWithFrame:CGRectMake(240, 150, 50, 50)];

To:

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(240, 150, 50, 50);

Thanks for reading, if you liked this then please share it!


  •  
  •  
  •  
  •  
  •  

Awesome Fun Music-Synced Animation With Video And Code

  •  
  •  
  •  
  •  
  •  

Found this great tutorial on creating a music synced animation.  The dancing effect is created by using a sound meter, and adjusting the size of the animation based on the sound level.  The end result looks terrific.

Check out the video:

The author was able to create this effect by using the open source Cocos2D engine for iPhone along with the CocosDenshion sound engine (included with Cocos2D iPhone).  It’s a really fun effect, and thanks to the author of the tutorial for providing full source code.

The full tutorial and code can be found here: Fun with cocosDenshion and Audio Metering

If you’re interested in having more fun with Cocos2D you may also want to check out our Cocos2D iPhone game engine resources page or our list of Great open-source Cocos2D apps.  It’s a great engine to look at once you’ve got the Objective-C basics down.

[via Cocos2D blog]


  •  
  •  
  •  
  •  
  •  

Animating A Game Sprite In Cocoa Touch

  •  
  •  
  •  
  •  
  •  

Something that can be very easily done using Cocoa Touch is animation.  This is a brief programming tutorial showing how it’s done.

The easiest way to do animation in Cocoa Touch is using the animationImages property from a view.
It’s a simple 3 step process.

1. Set animation images to an array containing your UIImages to be used for animating.
2. Set the duration to animate for.  (you can also set the number of times to repeat the animation for.)
3. Start the animation.

For example:

UIImageViewName.animationImages = arrayContainingImages
UiImageViewName.animationDuration = .. number of seconds ..
[UiImageViewName startAnimating]

More information on animationImages can be found in Apple’s UIImageView Class Reference here.

Brandon has posted a nice project here at: Animating A Game Sprite

[Via: iCodeBlog]


  •  
  •  
  •  
  •  
  •  

Programming Spinning, Scaling Images & Buttons: Code Snippet

  •  
  •  
  •  
  •  
  •  

A few days ago I posted a code snippet of a couple of methods that allowed you to fade a view in and out.  What I didn’t expect was a number of positive messages on youtube, but it made me realize that transforms and animations of UIViews are something that many probably haven’t played around with much.  So I decided to post another method showing how scaling can be used and the interesting effects that can be generated.

Check out the video:

If you’ve studied graphics math you probably know that when scaling reflection occurs if the provided scaling factor is a negative number, and because the scaling used here is done with a 2D matrix that is how the spin effect is produced which is also accompanied by shrinking (or growing).

The method I created to do this is pretty simplistic just like the one in the previous article on fading:
Scaling and Reflecting UI Views using CGAffineTransform


The key here is the CGAffineTransformMakeScale function which performs the matrix math for us with the x and y scaling factors provided.

The project I used to create the video is here:
>>> Scaling UIViews <<<
Something you’ll notice is that zero values are not used (0.01 is used in my project is the lowest scale) this is because providing zero as the scaling factor ends up zeroing everything out and causing the view being scaled to immediately be wiped from the screen.


Check it out, and hopefully you can use it to make your apps, especially your interfaces more interesting.
 


  •  
  •  
  •  
  •  
  •  

Code Snippet: Easy fading iPhone buttons, images, views

  •  
  •  
  •  
  •  
  •  

I was asked by a friend working on their first iPhone app if I could show them how to fade buttons to provide the user with visual feedback.  So I came up with this quick iPhone development tutorial using some source code that is actually from the second app that we I will be showing how to build in my iPhone development videos.

A very quick demonstration of the effect is shown in this video:

Fading a view on the iPhone is very easy you simply specify the ending alpha value, and duration, and commit the animations.  The views will then fade to the chosen alpha value.  Overall it’s a pretty sweet way to fade buttons, and images used in your interface especially if you’ve had to go through more complex techniques.

The code for the two methods to create the buttons is shown here: Source Code Snippet Fading Images, And Buttons On The iPhone

That’s all there is to it, it’s very plug and play so all you have to do is run the methods to perform the effect., and I’ve included some sample code with a project that has various views fading in and out based on which button is selected.  With a little bit of playing around you can make flashing images/buttons etc. 

The completed project can be downloaded here: >>> FadingViews <<<


  •  
  •  
  •  
  •  
  •