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
CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Advertisements

David Meredith Android: Animation David Meredith
Android View Properties & Animations
Graphics & Animation in Android. Android rendering options The Canvas API Renderscript OpenGL wrappers NDK OpenGL
Review of Java Applets Vijayan Sugumaran Decision and Information Sciences Oakland University.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 14 Applets, Images,
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Unity 3D game IDE 1.  Unity is a multi-platform, integrated IDE for scripting games, and working with 3D virtual worlds  Including:  Game engine ▪
Web Design & Development Lecture 18. Java Graphics.
Custom Views, Drawing, Styles, Themes, ViewProperties, Animations, oh my!
Sprite Animation CSE 391 Fall 2012 Tony Scarlatos.
Lecture Series on Android Programming Lecturer: Prof.Luqun Li Teaching Assistants: Fengyou Sun, Haijun Yang, Ting.
Chapter 12 Applets and Advanced Graphics  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets.
Chapter 10: Move! Creating Animation
WMD Creating Animations Flash-5 Zhou Hong. Contents Review 1 Frame Types 2 Frame-by-Frame Animation 3 Action & Shape Tweening 4.
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 
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
DUE Hello World on the Android Platform.
Animation.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Chapter 12 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
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.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Introduction to Processing. 2 What is processing? A simple programming environment that was created to make it easier to develop visually oriented applications.
Animations 1 Fall 2012 CS2302: Programming Principles.
Review 2 – Adobe Flash Lab Manual
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
CS324e - Elements of Graphics and Visualization Timing Framework.
Mobile Programming Lecture 11 Animation and TraceView.
ANDROID AND MODEL / VIEW / CONTROLLER. Slide 2 Design Patters Common solutions to programming problems are called design patterns Design patterns are.
Basic Animation. Animation 4 options – Animated.gif – Frame by Frame animation – Tweened animation This is our focus – OpenGL ES Graphics API for more.
Slide 1 VB Graphics Controls & Timer Control. Slide 2 Default Controls.
© 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.
XP Tutorial 3 Creating Animations. XP New Perspectives on Macromedia Flash MX Elements of Animation Layers are used to organize the content of.
Mobile Computing Lecture#12 Graphics & Animation.
Sci Vis I Exam Review Unit 6 Animation. Created when still images are played in rapid succession so that they appear to produce images that are constantly.
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.
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
Graphics & Animation in Android
A First Look at GUI Applications Radio Buttons and Check Boxes
CS499 – Mobile Application Development
Lecture 3: Animation & Graphics
Instructor: Mazhar Hussain
Lecture 8: Graphics By: Eliav Menachi.
S.RENUKADEVI/AP/SCD/ANDROID - Notifications
MAD.
Android Mobile Application Development
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Mobile Computing With Android ACST 4550 Android Animation
Chapter 15 Event-Driven Programming and Animations
Lecture 3: Animation & Graphics
Lecture 8: Graphics By: Eliav Menachi.
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

Animation Pre-3.0 (Honeycomb) – View animation – anim folder within resources folder – Animation, AnimationUtils, AnimationListener, and AnimationSet are 4 of the primary classes – The View itself is animated View animation is still supported

Animation Since 3.0 (Honeycomb) – Property animation – animator folder within resources folder – ObjectAnimator and AnimatorSet are the 2 of the primary classes AnimatorInflator is used to inflate the.xml file if needed AnimatorListenerAdaptor is used to respond to end, start, repeat, and cancel if needed – A property of the View is animated One of the 4 traditional properties – scale, alpha, translate, rotate Other – text, background color, etc.

Tweened animation Components of tweened animation – Drawable image file (.png,.jpg,.gif) xml file ShapeDrawable instance – animator resource animator folder within the res folder must be created contains xml describing the animation – Java code ObjectAnimator class AnimatorSet class AnimatorListenerAdapter class (and AnimatorListener class) AnimatorInflater class

Animation examples

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

Rotate animation – in xml Rotate.xml example (within res/animator folder) <objectAnimator xmlns:android=" android:propertyName="rotationY" android:duration="1000" android:valueTo="360" android:valueType="floatType" /> Loading the.xml file ObjectAnimator oa = (ObjectAnimator)AnimatorInflater.loadAnimator(this, R.animator.my_rotate_xml_filename); oa.setTarget(my_imageview); oa.start();

Rotate animation – in Java code Rotate example – animation created in Java code ObjectAnimator oa1 = ObjectAnimator.ofFloat(my_image_view, "rotationY", 0f, 360f); oa1.setDuration(1000); oa1.start();

Translate animation – in xml Translate.xml example (within res/animator folder) <objectAnimator xmlns:android=" android:propertyName="translationX" android:duration="1000" android:valueFrom="0" android:valueTo="100" android:valueType="floatType" /> Loading the.xml file ObjectAnimator oa = (ObjectAnimator)AnimatorInflater.loadAnimator(this, R.animator.my_translate_xml_filename); oa.setTarget(my_imageview); oa.start();

Translate animation – in Java code Translate example – animation created in Java code ObjectAnimator oa1 = ObjectAnimator.ofFloat(my_image_view, " translationX", 0f, 100f); oa1.setDuration(1000); oa1.start();

Alpha animation – in xml Alpha.xml example (within res/animator folder) <objectAnimator xmlns:android=" android:propertyName= "alpha" android:duration="1000" android:valueFrom=“1" android:valueTo= ".25" android:valueType="floatType" /> Loading the.xml file ObjectAnimator oa = (ObjectAnimator)AnimatorInflater.loadAnimator(this, R.animator.my_alpha_xml_filename); oa.setTarget(my_imageview); oa.start();

Alpha animation – in Java code Alpha example – animation created in Java code ObjectAnimator oa1 = ObjectAnimator.ofFloat(my_image_view, "alpha", 1f,.25f); oa1.setDuration(1000); oa1.start();

Scale animation – in xml Scale.xml example (within res/animator folder) <objectAnimator xmlns:android=" android:propertyName="scaleX" android:duration="1000" android:valueFrom="1" android:valueTo=".25" android:valueType="floatType" /> Loading the.xml file ObjectAnimator oa = (ObjectAnimator)AnimatorInflater.loadAnimator(this, R.animator.my_scale_xml_filename); oa.setTarget(my_imageview); oa.start();

Scale animation – in Java code Scale example – animation created in Java code ObjectAnimator oa1 = ObjectAnimator.ofFloat(my_image_view, "scaleX", 1f,.25f); oa1.setDuration(1000); oa1.start();

Additional functionality setRepeatCount(int) – sets the number of times an animation should be repeated 0 is the default ObjectAnimator.INFINITE will continue indefinitely setRepeatMode(int) – ObjectAnimator.REVERSE will run the animation backward after running it forward Example: if repeatMode is 3 and mode is reverse, animation will run forward twice, then in reverse twice

Combining Animations

AnimatorSet class – Combine animations or sets – Play sequentially or together

AnimatorSet – in xml AnimatorSet.xml example (within res/animator folder) <set xmlns:android=" android:ordering="together"> <objectAnimator android:propertyName="scaleX" android:duration="1000" android:valueTo=".25" android:valueType="floatType" /> <objectAnimator android:propertyName="scaleY" android:duration="1000" android:valueTo=".25" android:valueType="floatType" /> Loading the.xml file AnimatorSet as = (AnimatorSet)AnimatorInflater.loadAnimator(this, R.animator.my_set_xml_filename); as.setTarget(my_imageview); as.start();

AnimatorSet – in Java code AnimatorSet example – animation created in Java code AnimatorSet as = new AnimatorSet(); ObjectAnimator oa1 = ObjectAnimator.ofFloat(image, "scaleX", 1f,.25f); ObjectAnimator oa2 = ObjectAnimator.ofFloat(image, "scaleY", 1f,.25f); as.setDuration(1000); as.play(oa1).with(oa2); as.start(); Options – with(), before(), after() – One AnimatorSet can play other AnimatorSets (can be defined in.xml or in Java) – An AnimatorSet does not respond to repeatCount() or repeatMode()

Listening for events associated with animations

Listening with Animators AnimatorListener interface is implemented, or AnimatorListenerAdapter class is subclassed – AnimatorListener interface onAnimationCancel() onAnimationEnd() onAnimationRepeat() onAnimationStart() – AnimatorListenerAdapter provides empty implementations of the 4 methods above often used if only 1, 2, or 3 of methods above are needed

AnimatorListenerAdapter example AnimatorSet mySet = new AnimatorSet() //Load animations into the set (the adapter can also be applied to an ObjectAnimator object) mySet.addListener(new AnimatorListenerAdapter () public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); //Code to execute when animation starts is put here public void onAnimationRepeat(Animator animation) { super.onAnimationRepeat(animation); //Code to execute when animation repeats is put here } });

AnimatorListener example AnimatorSet mySet = new AnimatorSet() //Load animations into the set (the adapter can also be applied to an //ObjectAnimator object) mySet.addListener(new AnimatorListener () { //Code here is similar to last slide, but all 4 methods must be implemented });