Back to project page diploma-assignment.
The source code is released under:
MIT License
If you think the Android project diploma-assignment 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.me.battlescreen; /* www . ja v a 2 s.c o m*/ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.scenes.scene2d.Actor; public class CleanBackground extends Actor { private int backWidth; private Texture backGround; private BattleScreen screen; private int startX; private int newX; private int currX; public CleanBackground(Texture t,BattleScreen s) { backGround=t; screen=s; } private void activateBitmap() { // TODO Auto-generated method stub Constants.WIDTH_CONST=(int) backGround.getWidth(); Constants.HEIGHT_CONST=(int) backGround.getHeight(); Constants.BACKWIDTH=backWidth; Constants.WIDTH_SCALE=backGround.getWidth()/ (float) (backWidth); Constants.HEIGHT_SCALE=Constants.HEIGHT_CONST/ (float) (this.getHeight()); } private void calculateWidth(){ backWidth=(int) (this.getHeight()*((double)backGround.getWidth()/ backGround.getHeight())); this.setWidth(backWidth); } public void restart(){ currX=0; this.setX(0); calculateWidth(); activateBitmap(); } public void startDrag(float rawX) { // TODO Auto-generated method stub startX=currX+(int)rawX; } public void endDrag() { // TODO Auto-generated method stub startX=-1; } public void drag(float rawX) { // TODO Auto-generated method stub int x=((int) rawX+currX) - startX; newX-=x; startX=((int) rawX+newX); if(newX<0) newX=0; else if (newX+screen.getWidth()>backWidth) newX=(int) (backWidth-screen.getWidth()); currX=newX; } @Override public void draw(Batch batch,float parentAlpha){ batch.draw(backGround,this.getX()-(int)currX, this.getY(),backWidth,this.getHeight()); } public int getCoordsX() { return currX; } }