2

I am trying to develop a libgdx game. i want to implement a selection screen. Till now i have implemented horizontal scrollpane and it is working fine. Now i want to implement scrolling on the click on the button. You can check the image attached. enter image description here

Abhinav singh
  • 1,448
  • 1
  • 14
  • 31

3 Answers3

0

Try instead to use json pack

This works for me:

_skin = new Skin();
    TextureAtlas buttonAtlas = new TextureAtlas("images/buttons.pack");
    _skin.addRegions(buttonAtlas);
    _textButtonStyle = new TextButtonStyle();
    _textButtonStyle.font = _game.getFont();
    _textButtonStyle.up = _skin.getDrawable("button-orange");
    _textButtonStyle.down = _skin.getDrawable("button-blue");

buttons.pack:

buttons.png
size: 234,195
format: RGBA8888
filter: Nearest,Nearest
repeat: none
button-orange
  rotate: false
  xy: 0, 0
  size: 236, 67
  split: 25, 25, 14, 14
  orig: 236, 67
  offset: 0, 0
  index: -1
button-blue
  rotate: false
  xy: 0, 67
  size: 236, 67
  split: 25, 25, 14, 14
  orig: 236, 67
  offset: 0, 0
  index: -1
button-navy
  rotate: false
  xy: 0, 134
  size: 236, 67
  split: 25, 25, 14, 14
  orig: 236, 67
  offset: 0, 0
  index: -1
TyM6JIep
  • 406
  • 8
  • 23
  • this answer is clickable in the button and change the button image.. but i Want to slide the button or popup. how to sliding the image ya popup ya button.. – Abhinav singh Oct 28 '14 at 13:01
  • Can you give an example of an image that you want? – TyM6JIep Oct 28 '14 at 15:05
  • example .. any car game car can be slide to choose and play .. in the same way i want to slide the car ya popup in libgdx game .. – Abhinav singh Oct 29 '14 at 05:17
  • If I understand correctly, you need a carousel. I added two buttons on the stage (right / left) and as many pictures as necessary to show the objects. When you click in the render method, I asked in a cycle through the objects position setPosition - visually carousel was obtained. If necessary, i will gladly share the code – TyM6JIep Oct 29 '14 at 06:35
  • but when i click the button than how to slide the image.. Example any Car Racing game when choose the car, slide the screen and choose the car. My problem is how to slide the car image in libgdx. – Abhinav singh Oct 29 '14 at 06:46
  • You should add this image to the stage as an actor(yourstage.add(yourimage)). To change the position, you must use the method setPosition(yourimage.setPosition(yourX, yourY)) – TyM6JIep Oct 29 '14 at 06:49
0

Try in create method

yourImage = new Image(new Texture("images/image.png"));
stage.add(yourImage);

Try in render method

 yourImage.setPosition(yourX, yourY)
TyM6JIep
  • 406
  • 8
  • 23
  • thanks but this is not my problem solution. my problem is how to slide ya translate animation in the image in LibGDX click the buttion. – Abhinav singh Oct 29 '14 at 09:35
  • Look here(https://github.com/libgdx/libgdx/tree/master/tests/gdx-tests/src/com/badlogic/gdx/tests), maybe find something worthwhile – TyM6JIep Oct 30 '14 at 12:34
0

for the answer look this link https://github.com/krustnic/HorizontalSlidingPane

Abhinav singh
  • 1,448
  • 1
  • 14
  • 31