Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 5 6 [7] 8 9 10
 61 
 on: 2014-09-30 20:26:14 
Started by matanui159 - Last post by hwinwuzhere
1  
2  
3  
4  
5  
try {
    Thread.sleep(-1000);
} catch (Exception ex) {
    ex.printStackTrace();
}


Oh and assuming that you're using the outdated and clunky way, the correct parameter should be:

1  
2  
3  
4  
5  
6  
7  
import java.awt.delorean.fluxcapacitor

try {
    Thread.sleep(-88);
} catch (Exception ex) {
    ex.printStackTrace();
}

 62 
 on: 2014-09-30 19:56:51 
Started by matanui159 - Last post by HeroesGraveDev
You're doing it wrong.

Comment out the indicated line:
1  
2  
3  
4  
5  
try {
    Thread.sleep(-1000);
} catch (Exception ex) {
    // ex.printStackTrace();
}


See? No more errors!

 63 
 on: 2014-09-30 19:42:40 
Started by pakito - Last post by pakito
Omg finally got it to work. Thanks for the help guys. All I did was adding stage.setCamera( cam ); to my render method and its working fine now.

 64 
 on: 2014-09-30 19:40:41 
Started by syszee - Last post by BurntPizza
1  
2  
3  
4  
5  
6  
7  
BitmapFont font;
String s;

float width = f.getBounds(s).width;

// center text horizontally at (x,y)
draw(s, x - width / 2,  y); // something like this


Alternatively experiment with
drawWrapped(Batch batch, java.lang.CharSequence str, float x, float y, float wrapWidth, BitmapFont.HAlignment alignment)
and just set wrap width high enough. This is in http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html

Or if you're using a monospaced font you can pad with spaces like you did in the OP. That's a giant hack though.

 65 
 on: 2014-09-30 19:27:05 
Started by pakito - Last post by pakito
Why are you trying to manually do this?...

There is no reason for any of this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
      if( Gdx.input.justTouched( ) ) {
         Vector3 touchPos = new Vector3();
         touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
         ZBGame.cam.unproject(touchPos);
         
         Actor actor = stage.hit( touchPos.x, touchPos.y, true );

         if( actor != null ) {
            // change the button color
           // Its working on mobile device when touch but not changing screen.
           actor.setColor((float)Math.random(), (float)Math.random(),
                        (float)Math.random(), 0.5f+0.5f*(float)Math.random());
         }
      }


All you have to do is setup the Stage, set it as the input processor, add listeners to your buttons and then call act/draw. The stage will listener for any events.

I don't get what you are trying to do here.

Yes you are right, I removed it already. Initially I thought addlistener isn't working on my mobile device hence I use input.touch as a test until I found out the following problem:



I've updated my show method to use my own batch with camera combined but it just doesn't seems to work. Any idea why?

My updated code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
public class GameScreen implements Screen {

   public final int VIRTUAL_WIDTH = 370;
   public final int VIRTUAL_HEIGHT = 640;

   public OrthographicCamera cam;
   public SpriteBatch batch;

   public GameScreen( ) {
      screenWidth = Gdx.graphics.getWidth();
      screenHeight = Gdx.graphics.getHeight();
     
      cam = new OrthographicCamera();
      cam.setToOrtho(false, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);

      batch = new SpriteBatch( );
      batch.setProjectionMatrix(cam.combined);
   }


@Override
   public void show() {
      // Stage doesn't seems to be using my own batch with camera combined :(
     stage = new Stage( game.VIRTUAL_WIDTH, game.VIRTUAL_HEIGHT, true, batch );
      Gdx.input.setInputProcessor(stage);

      TextureAtlas buttons = new TextureAtlas( Gdx.files.internal("data/milk.txt") );
      Skin skin = new Skin( buttons );
     
      ImageButtonStyle btnStyle = new ImageButtonStyle();
      btnStyle.up = skin.getDrawable( "optionsBtn");
      btnStyle.down = skin.getDrawable( "optionsBtn");
     
      ImageButton button = new ImageButton(btnStyle);
      button.setBounds( ZBGame.VIRTUAL_WIDTH/2-(121/2), ZBGame.VIRTUAL_HEIGHT/2-100,
                   button.getWidth(), button.getHeight());

      button.addListener(new ClickListener( ) {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
               game.setScreen(new OptionScreen( game ) );
               return true;
            }
         });
        }


@Override
   public void render(float delta) {
      Gdx.gl.glClearColor(1, 1, 1, 1);
      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
     
      stage.act(delta);
      stage.draw();
   }
}

 66 
 on: 2014-09-30 19:14:50 
Started by Norakomi - Last post by Catharsis
You should figure out the Gradle configuration issues as LibGDX will be pulled automatically from Maven and you'll update LibGDX versions used via the Gradle build config files as well. I am assuming without more info that the problem you are facing regards a mismatch in the Gradle config files the LibGDX project creator is outputting and the latest Android Studio Gradle / build setup.

Here is how you can verify which Gradle build number you should use. First create a normal Android app in Android Studio. This will be your reference, so that you can verify the Gradle config information. You'll want to look at the top level build.gradle file under your main project directory. The very top of it should look like this:

1  
2  
3  
4  
5  
6  
7  
8  
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}


Take note of the classpatch dependency for gradle version number; above this is "0.12.+"

Now create a LibGDX project and open the build.gradle file in the parent directory.

It may look like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
        classpath 'com.github.jtakakura:gradle-robovm-plugin:0.0.10'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = 'MyGame'
        gdxVersion = '1.2.0'
        roboVMVersion = '0.0.14'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}


If the top Gradle version number is different than the normal Android app you created previously then copy the version number from the normal Android app to the GDX build.gradle file. IE change "0.10.+" to "0.12.+"

Also when you first open up an Android studio project navigate to the directory and click on the top level build.gradle file instead of the top level parent directory.

To resynch the Gradle build in Android Studio you will either be prompted automatically when you make changes to the Gradle build files or what is handy is to kick off updating the Gradle build manually. You do this by selecting from the top Android Studio menu: Tools -> Android -> Sync Project with Gradle files 

If your gradle config is correct and in line with the Android Studio versions then Gradle will automatically pull down LibGDX and all dependencies such as RoboVM.

Don't manually include LibGDX as jar files as that will just complicate things and is not the way to set up a Gradle project especially since LibGDX is configured to pull from Maven repos automatically.

When you need to update your version of LibGDX you update the "gdxVersion" and "roboVMVersion" and then hit the sync project w/ gradle files option and the latest versions will be pulled down.

Again, without having more details on what you are facing this is my assumption of what might be holding you up. Gradle take a bit of time to wrap your head around, but is well worth understanding because it is a powerful build system that both Android Studio and LibGDX uses. Let me know if this helps!

 67 
 on: 2014-09-30 19:14:31 
Started by pakito - Last post by Gibbo3771
The cam.unproject is a very important requirement for touch. I made the same mistake. Smiley

He is unprojecting it, but the whole thing is just weird. He is manually checking for touch down, getting the position and storing it, the checking if it is over an actor and then triggering the actors touch methods...but you don't need to do any of that.

 68 
 on: 2014-09-30 18:48:17 
Started by bornander - Last post by bornander
So this project is pretty much feature complete, it now has 56 levels, a leader board ,15 (I think) achievements and the game play is not too buggy.

I am pushing it into beta-testing to tune the levels, if anyone is interested in trying it out please let me know and I'll add you to the Google+ group that is the group of beta-testers. I would appreciate any comments you might have.

 69 
 on: 2014-09-30 18:43:28 
Started by pakito - Last post by syszee
The cam.unproject is a very important requirement for touch. I made the same mistake. Smiley

 70 
 on: 2014-09-30 18:15:58 
Started by imagnity - Last post by Gibbo3771
Deserves more downloads.

Perhaps you should try some marketing?

Pages: 1 ... 5 6 [7] 8 9 10
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (28 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!