MOBILE

Mobile Phone Game Programming : Understanding Animation

11/29/2011 8:58:31 AM

Understanding Animation

Before getting into animation as it relates to mobile games, it’s important to understand the basics of what animation is and how it works. Let’s begin by asking this fundamental question: What is animation? Put simply, animation is the illusion of movement. Could it be that every animation you’ve ever seen is really just an illusion? That’s exactly right! And probably the most surprising animated illusion is one that captured attentions long before computers—the television. When you watch television, you see a lot of things moving around. But what you perceive as movement is really just a trick being played on your eyes.

Animation and Frame Rate

In the case of television, the illusion of movement is created when a rapid succession of images is displayed with slight changes in their appearance. The human eye perceives these changes as movement because of its low visual acuity, which means that your eyes are fairly easy to trick into believing the illusion of animation. More specifically, the human eye can be tricked into perceiving animated movement with as low as 12 frames of movement per second. It should come as no surprise that this animation speed is the minimum target speed for most computer games. Animation speed is measured in frames per second (fps).

Although 12fps is technically enough to fool your eyes into seeing animation, animations at speeds this low often end up looking somewhat jerky. Therefore, most professional animations use a higher frame rate. Television, for example, uses 30fps. When you go to the movies, you see motion pictures at about 24fps. It’s pretty apparent that these frame rates are more than enough to captivate your attention and successfully create the illusion of movement.

Gamer’s Garage

The reason for the difference between film and television frame rates has to do more with technical necessity than careful design or planning. In its early days, film speeds were as low as 16fps, but were eventually standardized at 24fps, which turned out being a good frame rate to accommodate sound reproduction. American television, also known as NTSC (National Television Standards Committee), came along later, and relied on the power line frequency as a timing reference. This frequency was (and still is) 60Hz, which results in a frame rate of 30fps. The fact that film and television frame rates are different means that films have to be converted to be shown on television.


Unlike television and motion pictures, mobile games are considerably more limited when it comes to frame rate. Higher frame rates in games correspond to much higher processor overhead, so mobile game developers are left to balance the frame rate against the limited system speed and resources. You may find yourself in the position of having to use simpler graphics in a game so that you can increase its frame rate and generate smoother animations.

When programming animation in mobile games, you typically can manipulate the frame rate a reasonable amount. The most obvious limitation on frame rate is the speed at which the mobile phone can generate and display the animation frames. Actually, the same limitation must be dealt with by game developers, regardless of the programming language or platform. When determining the frame rate for a game, you usually have some give and take in establishing a low enough frame rate to yield a smooth animation, while not bogging down the processor and overloading the system. But don’t worry too much about this right now. For now, just keep in mind that when programming animation for games, you are acting as a magician creating the illusion of movement.

Making the Move to Computer Animation

Most of the techniques used in computer animation have been borrowed or based on traditional animation techniques developed for animated films. The classic approach to handling traditional animation is to draw a background image separately from the animated objects that will be moving in the foreground. The animated objects are then drawn on clear celluloid sheets so that they can be overlaid on the background and moved independently. This type of animation is referred to as cel animation. Cel animation enables artists to save a great deal of time by drawing only the specific objects that change shape or position from one frame to the next. This explains why so many animated movies have detailed backgrounds with relatively simple animated characters.

As computer power improved in the last two decades, traditional animators saw the potential for automating many of their hands-on techniques. Computers enabled them to scan in drawings and overlay them with transparency, for example. This is a similar approach to cel animation, but with one big difference: The computer imposes no limitations on the number of overlaid images. Cel animation is limited because only so many cel sheets can be overlaid. The technique of overlaying objects with transparency is a fundamental form of computer game animation, as you soon find out.


Gamer’s Garage

Modern animated movies have officially proven that computer animation is for more than just games. Popular movies such as Toy Story, Ice Age, Monsters, Inc., Finding Nemo, and The Incredibles are great examples of how traditional animated movies are now being created solely on computers. Perhaps an even more advanced example of computer animation in movies is Final Fantasy, which is one of the first movies to use computer animation to simulate live action graphics throughout an entire film.


Although computers have certainly improved upon traditional animation techniques, the animation potential available to the game programmer is far more flexible than traditional techniques. As a programmer, you have access to each individual pixel of each bitmap image, and you can manipulate each of them to your heart’s desire.


2D Versus 3D Animation

There are two fundamental types of animation that you might consider using when creating mobile games: 2D and 3D. 2D animation involves objects moving or being manipulated within two dimensions. Objects in a 2D animation can still have a 3D look to them—they just can’t physically move in three dimensions. Many 2D animation techniques simulate 3D animation by altering the look of objects to simulate depth, but they aren’t truly 3D. As an example, an animation of a car driving off into the distance would involve the car getting smaller as it gets farther away. However, this isn’t necessarily a 3D animation because you can achieve the 3D effect by making the car image get smaller as it moves away. Although the end result is three-dimensional, the car is very much a 2D object.

Unlike 2D animation, 3D animation involves placing and manipulating objects in a three-dimensional virtual world. A 3D object is defined by a model rather than an image because an image is inherently two-dimensional. A 3D model specifies the shape of an object by a series of points, or vertices, in 3D space. In other words, a 3D model is a mathematical representation of a physical object. For this reason, 3D graphics and animation can get extremely complicated because they often rely on heavy-duty mathematical processing.

In reality, many games make use of a mixture of 2D and 3D graphics and animation. For example, the original Doom game uses 3D graphics for the building interiors. However, the monsters in the game are 2D graphics objects. The monsters have a 3D appearance, but they are represented by flat images on the screen.

This mixture of 2D and 3D graphics works great in Doom because the 2D monsters look realistic enough when blending into 3D surroundings. Of course, things have evolved since the original Doom game. Quake and other more modern 3D first-person shooters (FPS) now use 3D objects throughout the game.

Other  
  •  Synchronizing Mobile Data - Using Merge Replication (part 2) - Programming for Merge Replication
  •  Synchronizing Mobile Data - Using Merge Replication (part 1) - Using Good Design to Avoid Synchronization Failures
  •  Windows Phone 7 Advanced Programming Model : Advanced Data Binding (part 4) - Data Bind to Anything
  •  Windows Phone 7 Advanced Programming Model : Advanced Data Binding (part 3) - Showing Progress & Lazy Load Images
  •  Windows Phone 7 Advanced Programming Model : Advanced Data Binding (part 2) - Syndicated Services
  •  Windows Phone 7 Advanced Programming Model : Advanced Data Binding (part 1)
  •  Beginning Android 3 : The Input Method Framework - Fitting In
  •  Mobile Application Security : Mobile Geolocation - Geolocation Methods & Geolocation Implementation
  •  Mobile Application Security : SMS Security - Application Attacks & Walkthroughs
  •  iPad SDK : Popovers - The Stroke Width Popover
  •  iPad SDK : Popovers - The Font Size Popover
  •  Beginning Android 3 : The Input Method Framework - Tailored to Your Needs
  •  Beginning Android 3 : Working with Containers - Scrollwork
  •  Mobile Application Security : SMS Security - Protocol Attacks (part 2)
  •  Mobile Application Security : SMS Security - Protocol Attacks (part 1)
  •  Mobile Application Security : SMS Security - Overview of Short Message Service
  •  iPad SDK : Popovers - The Font Name Popover (part 2)
  •  iPad SDK : Popovers - The Font Name Popover (part 1)
  •  Beginning Android 3 : Working with Containers - Tabula Rasa
  •  Beginning Android 3 : Working with Containers - LinearLayout Example & The Box Model
  •  
    Top 10
    Nikon 1 J2 With Stylish Design And Dependable Image And Video Quality
    Canon Powershot D20 - Super-Durable Waterproof Camera
    Fujifilm Finepix F800EXR – Another Excellent EXR
    Sony NEX-6 – The Best Compact Camera
    Teufel Cubycon 2 – An Excellent All-In-One For Films
    Dell S2740L - A Beautifully Crafted 27-inch IPS Monitor
    Philips 55PFL6007T With Fantastic Picture Quality
    Philips Gioco 278G4 – An Excellent 27-inch Screen
    Sony VPL-HW50ES – Sony’s Best Home Cinema Projector
    Windows Vista : Installing and Running Applications - Launching Applications
    Most View
    Bamboo Splash - Powerful Specs And Friendly Interface
    Powered By Windows (Part 2) - Toshiba Satellite U840 Series, Philips E248C3 MODA Lightframe Monitor & HP Envy Spectre 14
    MSI X79A-GD65 8D - Power without the Cost
    Canon EOS M With Wonderful Touchscreen Interface (Part 1)
    Windows Server 2003 : Building an Active Directory Structure (part 1) - The First Domain
    Personalize Your iPhone Case
    Speed ​​up browsing with a faster DNS
    Using and Configuring Public Folder Sharing
    Extending the Real-Time Communications Functionality of Exchange Server 2007 : Installing OCS 2007 (part 1)
    Google, privacy & you (Part 1)
    iPhone Application Development : Making Multivalue Choices with Pickers - Understanding Pickers
    Microsoft Surface With Windows RT - Truly A Unique Tablet
    Network Configuration & Troubleshooting (Part 1)
    Panasonic Lumix GH3 – The Fastest Touchscreen-Camera (Part 2)
    Programming Microsoft SQL Server 2005 : FOR XML Commands (part 3) - OPENXML Enhancements in SQL Server 2005
    Exchange Server 2010 : Track Exchange Performance (part 2) - Test the Performance Limitations in a Lab
    Extra Network Hardware Round-Up (Part 2) - NAS Drives, Media Center Extenders & Games Consoles
    Windows Server 2003 : Planning a Host Name Resolution Strategy - Understanding Name Resolution Requirements
    Google’s Data Liberation Front (Part 2)
    Datacolor SpyderLensCal (Part 1)