Basic Animation. Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more.

Slides:



Advertisements
Similar presentations
1 CSCE 1030 Computer Science 1 Introduction to Object Oriented Programming.
Advertisements

Android View Properties & Animations
Graphics & Animation in Android. Android rendering options The Canvas API Renderscript OpenGL wrappers NDK OpenGL
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 14 Applets, Images,
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Basic Animation. Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more.
Basic Drawing Techniques
Lecture Series on Android Programming Lecturer: Prof.Luqun Li Teaching Assistants: Fengyou Sun, Haijun Yang, Ting.
Chapter 10: Move! Creating Animation
6-2 2D Graphics CSNB544 Mobile Application Development Thanks to Utexas Austin.
Chapter 2: Simplify! The Android User Interface
Flag Quiz App 1 CS7030: Mobile App Development. assets Folder 2 CS7030: Mobile App Development  drawable folder – Image contents at the root level 
Copyright© Jeffrey Jongko, Ateneo de Manila University Android.
Animation.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 7: Reveal! Displaying Pictures in a GridView.
Android Boot Camp for Developers Using Java, 3E
Chapter 7: Reveal! Displaying Pictures in a Gallery.
C#/Java Classes ISYS 350. Introduction to Classes A class is the blueprint for an object. – It describes a particular type of object. – It specifies the.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
ECE122 Feb. 22, Any question on Vehicle sample code?
MIRALab Where Research means Creativity SVG Open 2005 University of Geneva 1 Converting 3D Facial Animation with Gouraud shaded SVG A method.
Chapter 5: Ball Worlds Features 2 classes, constant data fields, constructors, extension through inheritance, graphics.
Animations 1 Fall 2012 CS2302: Programming Principles.
Topics Introduction Scene Graphs
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
CS324e - Elements of Graphics and Visualization Timing Framework.
Mobile Programming Lecture 11 Animation and TraceView.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Mobile Computing Lecture#12 Graphics & Animation.
Object Oriented Programming in Java Habib Rostami Lecture 10.
Flag Quiz Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 10: Move! Creating Animation 1 Android.
By: Eliav Menachi.  Android custom 2D graphics library  OpenGL ES 1.0 for high performance 3D graphics.
CHAPTER 5 Graphics Drawing Audio. Chapter objectives: Learn to draw to a canvas Examine the process of adding drawn elements and UI controls to a layout.
Lecture 3: Animation & Graphics Topics: Animation, Graphics, Drawing Date: Feb 2, 2016.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
The Flag Quiz app tests your ability to correctly identify 10 flags from various countries and territories.
To play, start slide show and click on circle Lesson 3 Lesson 3 Lesson 3 Lesson 4 Lesson Lesson 4.
Graphics & Animation Radan Ganchev Astea Solutions.
Chapter 2: Simplify! The Android User Interface
Android Application 2D Graphics cs.
Lecture 3: Animation & Graphics
Chapter 5: Enhancing Classes
A First Look at GUI Applications Radio Buttons and Check Boxes
滑動版面 建國科技大學 資管系 饒瑞佶 2013/7 V1.
CS499 – Mobile Application Development
Lecture 3: Animation & Graphics
Lecture 8: Graphics By: Eliav Menachi.
S.RENUKADEVI/AP/SCD/ANDROID - Notifications
Creation of an Android App By Keith Lynn
Java Programming: Guided Learning with Early Objects
Mobile Computing With Android ACST 4550 Android Animation
Learning Objectives Build an app involving several activities
Interfaces.
Recitation 7 October 7, 2011.
Lecture 3: Animation & Graphics
Lecture 8: Graphics By: Eliav Menachi.
CS 1054: Lecture 2, Chapter 1 Objects and Classes.
Presentation transcript:

Basic Animation

Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more robust animation – Popular for mobile game programming – Supports 3D

Tweened animation Components of tweened animation – Drawable image file (.png,.jpg,.gif) xml file ShapeDrawable instance – Anim resource anim folder within the res folder must be created contains xml describing the animation – Java code AnimationUtils class Animation class AnimationListener class AnimationSet class

Anim resource anim folder within res folder

Tweened animation Types of tweened animation – rotate (spin) – translate (move) – alpha (fade) – scale (shrink/stretch)

Tweened animation Rotate options – Setting rotation parameters fromDegrees toDegrees – Setting the pivot point pivotX pivotY – Duration duration – time in milliseconds

Tweened animation Sample rotate.xml file <rotate xmlns:android=" android:fromDegrees="0" android:toDegrees="720" android:pivotX="25%" android:pivotY="75%" />

Tweened animation Translate options – Setting movement parameters toXDelta – positive is number of pixels to the right toYDelta – positive is number of pixels down – Duration duration – time in milliseconds

Tweened animation Sample translate.xml file <translate xmlns:android=" android:toYDelta="80" android:duration="1000" />

Tweened animation Alpha options – Setting alpha (transparency) parameters fromAlpha and toAlpha – Number between 0.0 and 1.0 – 1.0 is non-transparent, 0.0 is fully-transparent – Duration duration – time in milliseconds

Tweened animation Sample alpha.xml file <alpha xmlns:android=" android:fromAlpha= "0.75" android:toAlpha="0.25" android:duration="2000" />

Tweened animation Scale options – Setting scaling (shrink/stretch) parameters fromXScale and toXScale (or YScale) – numbers are relative to each other – Setting the pivot point pivotX pivotY – Duration duration – time in milliseconds

Tweened animation Sample scale.xml file <scale xmlns:android=" android:fromXScale="1.0" android:toXScale="0.33" android:fromYScale="1.0" android:toYScale="0.33" android:pivotX="50%" android:pivotY="50%" android:duration="5000" />

Java code Relevant animation classes

AnimationUtils class – a way to manage animations – loadAnimation ties an animation xml file to an instance of an Animation

Animation class – An animation that can be applied to views – relevant methods setRepeatCount – default is 0 setFillAfter – If argument is true, Animation persists after it ends » i.e. If object is moved, it stays where it was moved to – default is false setAnimationListener – a way to execute code as soon as an animation starts, repeats, or ends – must assign a user defined class that extends AnimationListener

Sample code Single animation – without Listener ImageView iv = (ImageView)findViewById(R.id.myIV); Animation an = AnimationUtils.loadAnimation(this, R.anim.myXMLFile); an.setRepeatCount(3); iv.startAnimation(an);

AnimationListener class Allows an Animation to ‘Listen’ for: – animation start – animation repeat – animation end Is often written as an Inner class

AnimationListener sample code class MyAnimationListener implements AnimationListener { public void onAnimationEnd(Animation animation) { //Code to execute when animation ends } public void onAnimationRepeat(Animation animation) { //Code to execute when animation repeats } public void onAnimationStart(Animation animation) { //Code to execute when animation starts }

Sample code Single animation – with Listener ImageView iv = (ImageView)findViewById(R.id.myIV); Animation an = AnimationUtils.loadAnimation(this, R.anim.myXMLFile); an.setRepeatCount(3); an.setAnimationListener(new MyAnimationListener()); iv.startAnimation(an);

AnimationSet Collection of a group of animations that will be played simultaneously Any properties set at the AnimationSet level override properties at individual Animation level – duration Constructor accepts boolean – true for our purposes – indicates to share an Interpolator (allows acceleration and deceleration of animation) Sets can listen in the same way individual animations can Known issue – Sets do not respond to setRepeatCount()

AnimationSet – implemented via java ImageView iv = (ImageView)findViewById(R.id.myImageView); AnimationSet animations = new AnimationSet(true); Animation an1 = AnimationUtils.loadAnimation(this, R.anim.xmlFile1); animations.addAnimation(an1); Animation an2 = AnimationUtils.loadAnimation(this, R.anim.xmlFile2); animations.addAnimation(an2); animations.setDuration(4000); iv.startAnimation(animations);

AnimationSet – implemented via xml Advantage of doing a set in xml is that each animation can be given a different duration (duration cannot be put at the set level in xml) <translate android:toYDelta="80" android:duration="10000" /> <alpha android:fromAlpha="0.75" android:toAlpha="0.25" android:duration= "2000" android:startOffset= "4000" />

AnimationSet – implemented via xml Java code treats as normal animation ImageView iv = (ImageView)findViewById(R.id.myIV); Animation an = AnimationUtils.loadAnimation(this, R.anim.myAnimXMLFile); iv.startAnimation(an);