2

variables:

int sourceX = 0;

create() method:

texture = new Texture(Gdx.files.internal("background.jpg"));
texture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);

render() method:

batch.begin();
sourceX+=velocitaScorrimentoSfondo;
batch.draw(texture, 0, 0, sourceX, 0, (int) texture.getWidth(), (int) texture.getHeight());
batch.end();

my goal is to run in the background automatically . from left to right . We did but on iOS , when I start the simulator with RoboVM scrolling does not work , that is, I do not see the background . while the simulator genymotion , and , on physical devices Android , the whole works . using the Actor ( Image ) everything works , only the draw will not do. Or if someone advises me how to slide the background Actor , transform the background sliding Actor. It ' may have graphics libraries ? How can I fix ? If you want other code write it in the comments .

Mr. Developer
  • 3,295
  • 7
  • 43
  • 110

1 Answers1

0

Make sure the background texture is a square, and its dimensions are powers of 2, like 256x256, 512x512 or 1024x1024. OpenGL 2.0 compatible devices support drawing textures that do not abide by this rule, but TextureWrapping/Repeating can be problematic.

I had that issue before, here's the badlogicgames forum link to the thread if you're interested.

http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=16695&p=71424#p71424

tdgtyugdyugdrugdr
  • 786
  • 4
  • 13
  • 31
  • excuse but the iPhone does not have the open GL 2.0 ? It should be supported , or am I wrong ? – Mr. Developer Nov 17 '15 at 13:46
  • You are using TextureWrapping, it can fail even on OpenGL 2.0 devices with nonsquare non pw2 textures. – tdgtyugdyugdrugdr Nov 17 '15 at 13:52
  • But then it should do it on Android devices do not square , I am using the galaxy s3 in the simulator and it works – Mr. Developer Nov 17 '15 at 13:54
  • Please read the forum link I've provided in the answer. It might or might not work, depending on the device. – tdgtyugdyugdrugdr Nov 17 '15 at 13:55
  • can you see this ? https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures maybe is solution – Mr. Developer Nov 17 '15 at 14:09
  • Yes, even the link you provided says the same thing I'm saying. I do not know what more you are asking. Do not use textures that are not square and are not powers of two. That is it. That's the answer to your question. Please try it, and ask follow up questions if it does not work. – tdgtyugdyugdrugdr Nov 17 '15 at 14:13
  • The OGL ES 2.0 spec does not require non-POT textures to support wrapping. But some specific GPUs support it anyway, as the one on the Galaxy S3 apparently does. Genymotion uses the desktop GPU which almost always supports it. – Tenfour04 Nov 17 '15 at 14:25
  • no way to scroll the background by placing it in an Actor? I saw ParallaxBackground , should do to my case – Mr. Developer Nov 17 '15 at 14:30