Hi I am trying to make a texture vertically scrollable and am not able to get the correct behaviour.
Here is my code:
if (Gdx.input.isTouched()) {
if (startingy == 0 ) {
startingy = (Gdx.input.getY())
/ (Gdx.graphics.getHeight() / MainGame.HEIGHT);
}
else if(getstart){
startingy = startingy-scroll;
getstart = false;
}
scroll = (Gdx.input.getY())
/ (Gdx.graphics.getHeight() / MainGame.HEIGHT);
if (startingy -scroll < 0) {
startingy = 0;
scroll = 0;
}
if (startingy > img.getHeight()) {
startingy = img.getHeight();
}
} else {
getstart = true;
}
Any help would be much appreciated, thankyou!
Why don't you make it easier for yourself and use an InputListener
and the touchDragged
method. https://github.com/libgdx/libgdx/wiki/Event-handling
When you have made an InputListener
class you can simply set it as a listener by:
Gdx.input.setInputProcesser(myProcesser);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.