SlideShare a Scribd company logo
1 of 7
Download to read offline
In above scenarion Animator class,
Actor pikachu=new Actor ("pickachu.png", 100, 50);
object reference variable is pikachu. Then it can used to call all the methods which are inside the
Actor class
I wrote the "turnto" method by helping of "Movto" method.
Here is the example of Animator class
public class Animator {
public Animator() {
}
public static void main(String[] args) {
Actor actor = new Actor();
actor.turnto(10,10000);
}
}
I used to pass two parameters which are degree of rotation and sleep time period
This Is Actor class after adding turnto method in addition to moveto method. In Here I Wrote
only the turnto method code only
package com.app.test;
public class Actor {
public Actor() {
actor = new Actor();
}
private Actor actor;
private int x, y, startx, starty;
private int rotate_Degree;
private long starttime;
private long duration;
private boolean interpolation;
private float currentScale = 1;
private float destScale = 1;
private float startScale = 1;
private boolean interpolationScale;
public Actor(String filename,int rotate_Degree){
x=rotate_Degree;
actor = EZ.addImage(filename,rotate_Degree);
actor.translateTo(x,y);;
interpolation = false;
interpolationScale = false;
}
public void turnto(int deg, long dur){
rotate_Degree = deg;
duration = dur*1000;
starttime = System.currentTimeMillis();
System.out.println(starttime);
startx=x;
interpolation = true;
interpolationScale = false;
}
public void setScale(float s, float dur){
destScale = s;
starttime = System.currentTimeMillis();
startScale = currentScale;
interpolationScale = true;
}
public boolean moving() {
return interpolation;
}
public boolean scaling() {
return interpolationScale;
}
public void go(){
if (interpolation == true) {
float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration;
x = (int) (startx + ((float) (rotate_Degree - startx) * normTime));
if ((System.currentTimeMillis() - starttime) >= duration) {
interpolation = false;
x = rotate_Degree;
}
// Dont forget to move the image itself.
pikachu.translateTo(x,y);
}
if (interpolationScale == true){
float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration;
currentScale = (startScale + ((float) (destScale - startScale) * normTime));
if ((System.currentTimeMillis() - starttime) >= duration) {
interpolationScale = false;
currentScale = destScale;
}
actor.scaleTo(currentScale);
}
}
}
Solution
In above scenarion Animator class,
Actor pikachu=new Actor ("pickachu.png", 100, 50);
object reference variable is pikachu. Then it can used to call all the methods which are inside the
Actor class
I wrote the "turnto" method by helping of "Movto" method.
Here is the example of Animator class
public class Animator {
public Animator() {
}
public static void main(String[] args) {
Actor actor = new Actor();
actor.turnto(10,10000);
}
}
I used to pass two parameters which are degree of rotation and sleep time period
This Is Actor class after adding turnto method in addition to moveto method. In Here I Wrote
only the turnto method code only
package com.app.test;
public class Actor {
public Actor() {
actor = new Actor();
}
private Actor actor;
private int x, y, startx, starty;
private int rotate_Degree;
private long starttime;
private long duration;
private boolean interpolation;
private float currentScale = 1;
private float destScale = 1;
private float startScale = 1;
private boolean interpolationScale;
public Actor(String filename,int rotate_Degree){
x=rotate_Degree;
actor = EZ.addImage(filename,rotate_Degree);
actor.translateTo(x,y);;
interpolation = false;
interpolationScale = false;
}
public void turnto(int deg, long dur){
rotate_Degree = deg;
duration = dur*1000;
starttime = System.currentTimeMillis();
System.out.println(starttime);
startx=x;
interpolation = true;
interpolationScale = false;
}
public void setScale(float s, float dur){
destScale = s;
starttime = System.currentTimeMillis();
startScale = currentScale;
interpolationScale = true;
}
public boolean moving() {
return interpolation;
}
public boolean scaling() {
return interpolationScale;
}
public void go(){
if (interpolation == true) {
float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration;
x = (int) (startx + ((float) (rotate_Degree - startx) * normTime));
if ((System.currentTimeMillis() - starttime) >= duration) {
interpolation = false;
x = rotate_Degree;
}
// Dont forget to move the image itself.
pikachu.translateTo(x,y);
}
if (interpolationScale == true){
float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration;
currentScale = (startScale + ((float) (destScale - startScale) * normTime));
if ((System.currentTimeMillis() - starttime) >= duration) {
interpolationScale = false;
currentScale = destScale;
}
actor.scaleTo(currentScale);
}
}
}

More Related Content

Similar to In above scenarion Animator class,Actor pikachu=new Actor (picka.pdf

Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
lykado0dles
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 

Similar to In above scenarion Animator class,Actor pikachu=new Actor (picka.pdf (20)

Hope driven development
Hope driven developmentHope driven development
Hope driven development
 
Class & Objects in JAVA.ppt
Class & Objects in JAVA.pptClass & Objects in JAVA.ppt
Class & Objects in JAVA.ppt
 
.NET F# Events
.NET F# Events.NET F# Events
.NET F# Events
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloadingJavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloadingJavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
 
Ngrx meta reducers
Ngrx meta reducersNgrx meta reducers
Ngrx meta reducers
 
Neoito — Animations in Angular 5
Neoito — Animations in Angular 5Neoito — Animations in Angular 5
Neoito — Animations in Angular 5
 
Bc0037
Bc0037Bc0037
Bc0037
 
Qt Animation
Qt AnimationQt Animation
Qt Animation
 
Akka
AkkaAkka
Akka
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
JAVA Question : Programming Assignment
JAVA Question : Programming AssignmentJAVA Question : Programming Assignment
JAVA Question : Programming Assignment
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
 
Chap08
Chap08Chap08
Chap08
 
Array Cont
Array ContArray Cont
Array Cont
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++
 
3d7b7 session4 c++
3d7b7 session4 c++3d7b7 session4 c++
3d7b7 session4 c++
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 

More from info30292

The vagus nerve is the longest cranial nerve. It contains motor and .pdf
The vagus nerve is the longest cranial nerve. It contains motor and .pdfThe vagus nerve is the longest cranial nerve. It contains motor and .pdf
The vagus nerve is the longest cranial nerve. It contains motor and .pdf
info30292
 
So, you know that atoms have electrons. But how are they organized a.pdf
So, you know that atoms have electrons. But how are they organized a.pdfSo, you know that atoms have electrons. But how are they organized a.pdf
So, you know that atoms have electrons. But how are they organized a.pdf
info30292
 
Rutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdfRutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdf
info30292
 
Process improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdfProcess improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdf
info30292
 
From psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdfFrom psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdf
info30292
 
Check listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdfCheck listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdf
info30292
 

More from info30292 (20)

Use the Henderson eqn pOH = pKb + log(baseacid).pdf
                     Use the Henderson eqn pOH = pKb + log(baseacid).pdf                     Use the Henderson eqn pOH = pKb + log(baseacid).pdf
Use the Henderson eqn pOH = pKb + log(baseacid).pdf
 
The purpose is to protonate the ether present the.pdf
                     The purpose is to protonate the ether present the.pdf                     The purpose is to protonate the ether present the.pdf
The purpose is to protonate the ether present the.pdf
 
no reaction since in metal activity series Zn is .pdf
                     no reaction since in metal activity series Zn is .pdf                     no reaction since in metal activity series Zn is .pdf
no reaction since in metal activity series Zn is .pdf
 
nuclei can contain different numbers of neutrons..pdf
                     nuclei can contain different numbers of neutrons..pdf                     nuclei can contain different numbers of neutrons..pdf
nuclei can contain different numbers of neutrons..pdf
 
KOH is a base as will yield OH-. FeSO4 is a salt.pdf
                     KOH is a base as will yield OH-.  FeSO4 is a salt.pdf                     KOH is a base as will yield OH-.  FeSO4 is a salt.pdf
KOH is a base as will yield OH-. FeSO4 is a salt.pdf
 
The vagus nerve is the longest cranial nerve. It contains motor and .pdf
The vagus nerve is the longest cranial nerve. It contains motor and .pdfThe vagus nerve is the longest cranial nerve. It contains motor and .pdf
The vagus nerve is the longest cranial nerve. It contains motor and .pdf
 
Solution 3-2Following are the basic users of financial statements.pdf
Solution 3-2Following are the basic users of financial statements.pdfSolution 3-2Following are the basic users of financial statements.pdf
Solution 3-2Following are the basic users of financial statements.pdf
 
So, you know that atoms have electrons. But how are they organized a.pdf
So, you know that atoms have electrons. But how are they organized a.pdfSo, you know that atoms have electrons. But how are they organized a.pdf
So, you know that atoms have electrons. But how are they organized a.pdf
 
Rutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdfRutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdf
 
Raising the pH will increase the basicity of the solution.Since su.pdf
Raising the pH will increase the basicity of the solution.Since su.pdfRaising the pH will increase the basicity of the solution.Since su.pdf
Raising the pH will increase the basicity of the solution.Since su.pdf
 
Process improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdfProcess improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdf
 
Net operating assets = operating assets-operating liabilitiesNet o.pdf
Net operating assets = operating assets-operating liabilitiesNet o.pdfNet operating assets = operating assets-operating liabilitiesNet o.pdf
Net operating assets = operating assets-operating liabilitiesNet o.pdf
 
import java.util.; public class NaturalNumberTriangle { publi.pdf
import java.util.; public class NaturalNumberTriangle { publi.pdfimport java.util.; public class NaturalNumberTriangle { publi.pdf
import java.util.; public class NaturalNumberTriangle { publi.pdf
 
HNO3 is a strong acid pH = -log[H+] = -log[0.05] = 1.3p.pdf
HNO3 is a strong acid  pH = -log[H+] = -log[0.05] = 1.3p.pdfHNO3 is a strong acid  pH = -log[H+] = -log[0.05] = 1.3p.pdf
HNO3 is a strong acid pH = -log[H+] = -log[0.05] = 1.3p.pdf
 
From psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdfFrom psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdf
 
Formatting and code conversion occurs in the Presentation layer of t.pdf
Formatting and code conversion occurs in the Presentation layer of t.pdfFormatting and code conversion occurs in the Presentation layer of t.pdf
Formatting and code conversion occurs in the Presentation layer of t.pdf
 
Correct answer is option A. As epistasis occurs when the effect of o.pdf
Correct answer is option A. As epistasis occurs when the effect of o.pdfCorrect answer is option A. As epistasis occurs when the effect of o.pdf
Correct answer is option A. As epistasis occurs when the effect of o.pdf
 
Cloud computingIt is a kind of net based computing that gives sha.pdf
Cloud computingIt is a kind of net based computing that gives sha.pdfCloud computingIt is a kind of net based computing that gives sha.pdf
Cloud computingIt is a kind of net based computing that gives sha.pdf
 
Check listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdfCheck listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdf
 
ans C it is a process of forming diazo compund .pdf
                     ans C it is  a process of forming diazo compund  .pdf                     ans C it is  a process of forming diazo compund  .pdf
ans C it is a process of forming diazo compund .pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 

Recently uploaded (20)

AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 

In above scenarion Animator class,Actor pikachu=new Actor (picka.pdf

  • 1. In above scenarion Animator class, Actor pikachu=new Actor ("pickachu.png", 100, 50); object reference variable is pikachu. Then it can used to call all the methods which are inside the Actor class I wrote the "turnto" method by helping of "Movto" method. Here is the example of Animator class public class Animator { public Animator() { } public static void main(String[] args) { Actor actor = new Actor(); actor.turnto(10,10000); } } I used to pass two parameters which are degree of rotation and sleep time period This Is Actor class after adding turnto method in addition to moveto method. In Here I Wrote only the turnto method code only package com.app.test; public class Actor { public Actor() { actor = new Actor(); } private Actor actor; private int x, y, startx, starty; private int rotate_Degree; private long starttime; private long duration; private boolean interpolation; private float currentScale = 1; private float destScale = 1; private float startScale = 1;
  • 2. private boolean interpolationScale; public Actor(String filename,int rotate_Degree){ x=rotate_Degree; actor = EZ.addImage(filename,rotate_Degree); actor.translateTo(x,y);; interpolation = false; interpolationScale = false; } public void turnto(int deg, long dur){ rotate_Degree = deg; duration = dur*1000; starttime = System.currentTimeMillis(); System.out.println(starttime); startx=x; interpolation = true; interpolationScale = false; } public void setScale(float s, float dur){ destScale = s; starttime = System.currentTimeMillis(); startScale = currentScale; interpolationScale = true; } public boolean moving() { return interpolation; } public boolean scaling() {
  • 3. return interpolationScale; } public void go(){ if (interpolation == true) { float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration; x = (int) (startx + ((float) (rotate_Degree - startx) * normTime)); if ((System.currentTimeMillis() - starttime) >= duration) { interpolation = false; x = rotate_Degree; } // Dont forget to move the image itself. pikachu.translateTo(x,y); } if (interpolationScale == true){ float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration; currentScale = (startScale + ((float) (destScale - startScale) * normTime)); if ((System.currentTimeMillis() - starttime) >= duration) { interpolationScale = false; currentScale = destScale; } actor.scaleTo(currentScale); } } }
  • 4. Solution In above scenarion Animator class, Actor pikachu=new Actor ("pickachu.png", 100, 50); object reference variable is pikachu. Then it can used to call all the methods which are inside the Actor class I wrote the "turnto" method by helping of "Movto" method. Here is the example of Animator class public class Animator { public Animator() { } public static void main(String[] args) { Actor actor = new Actor(); actor.turnto(10,10000); } } I used to pass two parameters which are degree of rotation and sleep time period This Is Actor class after adding turnto method in addition to moveto method. In Here I Wrote only the turnto method code only package com.app.test; public class Actor { public Actor() { actor = new Actor(); } private Actor actor; private int x, y, startx, starty; private int rotate_Degree; private long starttime; private long duration; private boolean interpolation; private float currentScale = 1;
  • 5. private float destScale = 1; private float startScale = 1; private boolean interpolationScale; public Actor(String filename,int rotate_Degree){ x=rotate_Degree; actor = EZ.addImage(filename,rotate_Degree); actor.translateTo(x,y);; interpolation = false; interpolationScale = false; } public void turnto(int deg, long dur){ rotate_Degree = deg; duration = dur*1000; starttime = System.currentTimeMillis(); System.out.println(starttime); startx=x; interpolation = true; interpolationScale = false; } public void setScale(float s, float dur){ destScale = s; starttime = System.currentTimeMillis(); startScale = currentScale; interpolationScale = true; } public boolean moving() { return interpolation; }
  • 6. public boolean scaling() { return interpolationScale; } public void go(){ if (interpolation == true) { float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration; x = (int) (startx + ((float) (rotate_Degree - startx) * normTime)); if ((System.currentTimeMillis() - starttime) >= duration) { interpolation = false; x = rotate_Degree; } // Dont forget to move the image itself. pikachu.translateTo(x,y); } if (interpolationScale == true){ float normTime = (float) (System.currentTimeMillis() - starttime)/ (float) duration; currentScale = (startScale + ((float) (destScale - startScale) * normTime)); if ((System.currentTimeMillis() - starttime) >= duration) { interpolationScale = false; currentScale = destScale; } actor.scaleTo(currentScale); } }
  • 7. }