Back to project page catchanimals.
The source code is released under:
GNU General Public License
If you think the Android project catchanimals listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ricardorb.sprites; /* w w w. j a v a2 s . c o m*/ import com.badlogic.gdx.Gdx; import com.ricardorb.catchanimals.Assets; import com.ricardorb.catchanimals.CatchAnimals; import com.ricardorb.controllers.ControllerBasket; /** * Bucket of the game, the user will move the bucket in the game * * @author RicardoRB * */ public class Basket extends com.ricardorb.sprites.Element{ private static final int BUCKETVELX = 200; private ControllerBasket conBucket; public Basket(final CatchAnimals game, ControllerBasket conBucket) { super(Assets.basket,game); setPosition(game.WINDOWX / 2 - getWidth() / 2, 20f); setCenter(getWidth() / 2, getHeight() / 2); this.conBucket = conBucket; } public void update(){ //Move the bucket if(conBucket.isMoveR()){ setX(getX() + BUCKETVELX * Gdx.graphics.getDeltaTime()); }else if(conBucket.isMoveL()){ setX(getX() - BUCKETVELX * Gdx.graphics.getDeltaTime()); }else if(conBucket.isDrag()){ setPosition(conBucket.getDragX(), getY()); } //Bucket cant get out of the screen if (getX() < 0) { setX(0); } if (getX() > GAME.WINDOWX - getWidth()) { setX(GAME.WINDOWX - getWidth()); } rectangle.x = getX(); rectangle.y = getY(); } public static int getBucketvelx() { return BUCKETVELX; } }