[Solved]Intro Mobile Apps Need Help Assignment Using Android Studio Java Language Assignment Code Q37300676
I am in intro to mobile apps need help with this assignment weare using android studio and Java language the assignment and codeis below.

I am in intro to mobile apps need help with this assignment weare using android studio and Java language the assignment isbelow.
Using in this
- TouchEvents
- MVC
Please modify the Android AnimationExample (provided) byimplementing a paddle that reflects the ball when it hits it. Youshould use the touch event to control the movement of the paddle.In addition, you can try to use the accelerometer to control themovement of the paddle for possible extra-credit.The assignmentexample classes are is below.
AnimationView.java
import android.content.Context;import android.graphics.Canvas;import android.util.AttributeSet;import android.view.MotionEvent;import android.view.View;import java.util.ArrayList;import java.util.List;/** * AnimationView – offers a graphical view of a simple animated app * with BallSprites tat move around and bounce of the edges of the screen. */public class AnimationView extends View { private AnimationThread animationThread; private List<Sprite> spriteList; /** * Constructor that initializes this with two BallSprites and starts * and animation thread that moves the BallSprites around the * screen. * * @param context not null * @param attributeSet not null */ public AnimationView(Context context, AttributeSet attributeSet){ super(context, attributeSet); initAnimationView(); } private void initAnimationView(){ this.spriteList = new ArrayList<Sprite>(); Sprite sprite1 = new BallSprite(100, 100, 50, 50); sprite1.setSize(BallSprite.DEFAULT_SIZE, BallSprite.DEFAULT_SIZE); BallSprite sprite2 = new BallSprite(300, 300, 25, 25); sprite2.setSize(BallSprite.DEFAULT_SIZE, BallSprite.DEFAULT_SIZE); this.spriteList.add(sprite1); this.spriteList.add(sprite2); this.animationThread = new AnimationThread(this, AnimationThread.DEFAULT_FPS); this.animationThread.start(); } /** * draws the BallSprites on this View and * updates their position. * * @param canvas */ @Override public void onDraw(Canvas canvas){ super.onDraw(canvas); drawAllSprites(canvas); updateAllSprites(); } /** * draws all of Sprites in theList to this View. * * @param canvas should not be null */ private void drawAllSprites(Canvas canvas){ for(int index=0; index<this.spriteList.size(); index++){ Sprite sprite = this.spriteList.get(index); sprite.draw(canvas); } } /** * updates the location of all of the Sprites’ in theList */ private void updateAllSprites(){ for(int index=0; index<this.spriteList.size(); index++){ Sprite sprite = this.spriteList.get(index); sprite.updateLocation(this.getWidth(), this.getHeight()); } } /** * recocgnizes a user’s touch or tapping of the screen and reverses * the velocity (x and y) for all of the Sprites in theList. * @param motionEvent should not be null * @return the parent’s onTouchEvent */ @Override public boolean onTouchEvent(MotionEvent motionEvent){ float xTouch = motionEvent.getX(); float yTouch = motionEvent.getY(); for(int index=0; index<spriteList.size(); index++){ Sprite sprite = spriteList.get(index); float xVel = sprite.getxVelocity(); float yVel = sprite.getyVelocity(); sprite.setxVelocity(xVel * -1); sprite.setyVelocity(yVel * -1); } return super.onTouchEvent(motionEvent); }}
BallSprite.java
import android.graphics.Canvas;/** * Represents s Sprite in the shape of a Ball * @author Clint Fuchs * @email clintf@coastal.edu * @course CSCI 343 */public class BallSprite extends Sprite { public final static float DEFAULT_SIZE = 100.0f; public BallSprite(float xLoc, float yLoc, float xVel, float yVel){ super(xLoc, yLoc, xVel, yVel); } /** * draws this onto the Canvas parameter * @param canvas – not null medium for drawing this on for */ @Override public void draw(Canvas canvas){ canvas.drawOval(super.getRect(), super.getPaint()); }}
Sprite.java
import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.RectF;/** * Sprite – this class is used to represent sprites, * which are in-game objects that can move around. * This class is fairly simple and is just meant to gather together * several variables that would be associated with in-game sprite objects * such as x/y location, width/height size, dx/dy velocity, and Paint color. * */public abstract class Sprite { /** * represents the bounds of this as represented by * a rectangle */ private RectF rect = new RectF(); private float xVelocity = 0.0f; private float yVelocity = 0.0f; private Paint paint = new Paint(Color.BLUE); /** * Sprite constructor * * @param locX – top left x coordinate of this Sprite * @param locY – top left y coordinate of this Sprite * @param xVel – x velocity of this Sprite * @param yVel – y velocity of this Sprite */ public Sprite(float locX, float locY, float xVel, float yVel){ rect.offsetTo(locX, locY); xVelocity = xVel; yVelocity = yVel; } /** * setLocation – sets the Sprite’s x,y location on * screen to be the given values. * @param x – represents the top left x coordinate * @param y – represents the top left y coordinate */ public void setLocation(float x, float y){ rect.offsetTo(x, y); } /** * setVelocity – sets the velocity of the Sprite * @param x – x velocity * @param y – y velocity */ public void setVelocity(float x, float y){ xVelocity = x; yVelocity = y; } /** * setSize – sets the Sprite’s size to the given values * * @param width * @param height */ public void setSize(float width, float height){ //rect.offset(width, height); rect.set(rect.left, rect.top, (rect.left+width), (rect.top +height)); } /** * move – tells the sprite to move itself by its current velocity dx,dy. */ public void move(){ rect.offset(xVelocity, yVelocity); } /** * updateLocation – moves the Sprite while checking to see if * the Sprite is about to go out of the bounds of the params * width and height reversing the velocity of this if it * goes out the bounds of the width and/or height. * * @param width – represents the width of the View the Sprite * is drawn in. * @param height – represents the height of the View the Sprite * is drawn in. */ public void updateLocation(float width, float height){ this.move(); // handles Sprite reaching the left or right side // of the view by reversing the xVelocity if(rect.left < 0 || rect.right > width){ xVelocity = xVelocity * -1; } // handles Sprite reaching the top or bottom // of the View by reversing the yVelocity if(rect.top < 0 || rect.bottom > height){ yVelocity *= -1; } } // accessors and mutators public RectF getRect() { return rect; } public void setRect(RectF rect) { this.rect = rect; } public float getxVelocity() { return xVelocity; } public void setxVelocity(float xVelocity) { this.xVelocity = xVelocity; } public float getyVelocity() { return yVelocity; } public void setyVelocity(float yVelocity) { this.yVelocity = yVelocity; } public Paint getPaint() { return paint; } public void setPaint(Paint paint) { this.paint = paint; } /** * draws this according to the type of Sorite is subclassed * @param canvas – not null medium for drawing this on for * presentation */ public abstract void draw(Canvas canvas);}Lab07 CSCI 343: Lab 7 Paddle Objectives In this week’s lab you will learn about TouchEvents MVC Plesse modity the Android AnimationExample (provided) by implementing a padda that refiects the ball when t hts t. You should use the touch event to control the movemert of the paddle. In aclcition, you con try to use the accelerometer to control the movement of the paddle for possible extra-credit Files to Upload for this Lab: Lab07 zip The source code must be indented properly and cortain comments that descrbe important perts of the aigorthm. The use of proper Indentation is considered good programming style, and you are expected to use good programming style. Make sure that you upload your program to Moodie’s drop-box when you are done in order to receive credt for this lab. Show transcribed image text Lab07 CSCI 343: Lab 7 Paddle Objectives In this week’s lab you will learn about TouchEvents MVC Plesse modity the Android AnimationExample (provided) by implementing a padda that refiects the ball when t hts t. You should use the touch event to control the movemert of the paddle. In aclcition, you con try to use the accelerometer to control the movement of the paddle for possible extra-credit Files to Upload for this Lab: Lab07 zip The source code must be indented properly and cortain comments that descrbe important perts of the aigorthm. The use of proper Indentation is considered good programming style, and you are expected to use good programming style. Make sure that you upload your program to Moodie’s drop-box when you are done in order to receive credt for this lab.
Expert Answer
Answer to I am in intro to mobile apps need help with this assignment we are using android studio and Java language the assignment… . . .
OR

