Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: [LibGDX]Scene2d table cell layout problem on: 2013-08-19 23:04:52
thanks for the help.
I have since changed
Quote
1  
2  
3  
4  
5  
6  
 b.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            rClick.add(terrainMenu).row(); //why do you create a new row?
            terrainMenu.setVisible(true);
         }
      });

to
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
b.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            if(terrainMenu.isVisible()){
               rClick.removeActor(terrainMenu);
               terrainMenu.setVisible(false);
            }else{
               rClick.add(terrainMenu);
               terrainMenu.setVisible(true);
            }
         }

but still no joy. I was toying around with that .row() and moving it around to see if I could effect anything but even with it removed entirely and only using .addActor() the cell was on a new row.
I added everything to stage because thats how the tutorial I was following did it, though I have had to correct a few things already after looking at the official libGDX wiki. Should I only worry about adding the tables(other than the master table) to the main right click menu?
I'll remove that code adding everything to stage.

EDIT: the images and package file are in rts-desktop/bin/img
2  Game Development / Newbie & Debugging Questions / Re: [LibGDX]Scene2d table cell layout problem on: 2013-08-19 20:59:30
I am using multiple tables. I have:
>one root/master menu table
>the main right click menu table .add'ed to the master
>a button in the main right click menu should toggle master.add(terrainTable) and master.removeActor(terrainTable)

all of the above works, except for the fact it adds the terrain menu cell to a new row underneath the main right click menu where I want it to be added to the right of the main right click menu:

Here's the relevant code section:
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  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
public Gui(GameScreen game) {
      this.game = game;
      stage = new Stage();
      stage.setCamera(game.getRenderer().getCamera());
      font = game.getRenderer().getFont();
      //font.setUseIntegerPositions(false);
      skin = new Skin();
      skin.addRegions(game.getAtlas());
      lStyle = new LabelStyle();
     
      stage.addActor(terrainMenu());
      stage.addActor(infoMenu());
      stage.addActor(mainMenu());
      stage.addActor(bottomBar());
      stage.addActor(rightClickMenu());
     
     
//      rClick.add(terrainMenu);
//      rClick.add(infoMenu);
     
      rClick.debug();
   }
   
   //Base Right click menu
   public Table rightClickMenu() {

      rClick = new Table();
      rClick.setFillParent(false);
      rClick.left().top();
      rClick.setWidth(120);
      rClick.setHeight(60);
     
      rClick.add(mainMenu);
     
      return rClick;
   }
   
   public Table mainMenu(){
     
      mainMenu = new Table();
      mainMenu.defaults().width(45).height(15);

      mainMenu.setFillParent(false);
      //mainTable.setX(game.getInput().getVec2Clicked().x);
      //mainTable.setY(game.getInput().getVec2Clicked().y);

      lStyle.font = font;
      setButtonStyle("gui/menuItem_up");
     
      b = new Button(style);
      b.add(new Label("Info",lStyle));
      b.left();
      b.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            if(infoMenu.isVisible()){
               infoMenu.setVisible(false);
            }else{
               infoMenu.setVisible(true);
            }
         }
      });
      mainMenu.add(b).row();
     
      b = new Button(style);
      b.add(new Label("Terrain",lStyle));
      b.left();
      b.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            if(terrainMenu.isVisible()){
               rClick.removeActor(terrainMenu);
               terrainMenu.setVisible(false);
            }else{
               rClick.add(terrainMenu);
               terrainMenu.setVisible(true);
            }
         }
      });
      mainMenu.add(b).row();

      // Make a bunch of filler buttons
      for (int i = 0; i < 2; i++) {
         b = new Button(style);
         b.add(new Label("[EMPTY]",lStyle));
         b.left();
         b.addListener(new ChangeListener() {
            public void changed(ChangeEvent event, Actor actor) {
               //System.out.println("Wait");
            }
         });
         mainMenu.add(b).row();
      }
      mainMenu.left().bottom();
      mainMenu.setVisible(false);
      return mainMenu;
   }

//Terrain/Map tiles
   public Table terrainMenu(){
      terrainMenu = new Table();
      terrainMenu.setFillParent(false);
      terrainMenu.defaults().width(game.getAtlas().findRegion("terrain/grass").packedWidth+game.getAtlas().findRegion("terrain/grass").packedWidth*.25f).height(game.getAtlas().findRegion("terrain/grass").packedHeight+game.getAtlas().findRegion("terrain/grass").packedHeight*.25f);
      //terrainMenu.left();
     
      ImageButtonStyle style = new ImageButtonStyle();
      style.imageUp = skin.getDrawable("terrain/grass");
      style.up = skin.getDrawable("gui/menuItem_up");
      ImageButton imgb = new ImageButton(style);
      imgb.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            game.setBuildSelection(game.getBaseTiles().getBaseTile("grass"));
            System.out.println("Build selection set to grass... " + game.getBuildSelection());
         }
      });
      terrainMenu.add(imgb);
     
      style = new ImageButtonStyle();
      style.imageUp = skin.getDrawable("terrain/water");
      style.up = skin.getDrawable("gui/menuItem_up");
      imgb = new ImageButton(style);
      imgb.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            game.setBuildSelection(game.getBaseTiles().getBaseTile("water"));
            System.out.println("Build selection set to Water... " + game.getBuildSelection());
         }
      });
      terrainMenu.add(imgb).row();
     
      style = new ImageButtonStyle();
      style.imageUp = skin.getDrawable("terrain/road");
      style.up = skin.getDrawable("gui/menuItem_up");
      imgb = new ImageButton(style);
      imgb.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            game.setBuildSelection(game.getBaseTiles().getBaseTile("road"));
            System.out.println("Build selection set to road... " + game.getBuildSelection());
         }
      });
      terrainMenu.add(imgb).row();
     
      style = new ImageButtonStyle();
      style.imageUp = skin.getDrawable("terrain/markerTile");
      style.up = skin.getDrawable("gui/menuItem_up");
      imgb = new ImageButton(style);
      imgb.addListener(new ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
            game.setBuildSelection(game.getBaseTiles().getBaseTile("markerTile"));
            System.out.println("Build selection set to markerTile... " + game.getBuildSelection());
         }
      });
      terrainMenu.add(imgb).row();
     
      terrainMenu.setVisible(false);
      return terrainMenu;
   }


3  Game Development / Newbie & Debugging Questions / [LibGDX]Scene2d table cell layout problem on: 2013-08-19 01:44:31
hey all

I'm having a problem with this set of tables I'm using as a right click menu in my game. I have virtually everything finished with this part of the gui and I'm stuck on it now so a fresh set of eyes would be appreciated.


You can see in the screenshot and in the game if you download it how I would like the right click menu to layout the terrain tile menu to the right of the main right click menu by adding it to a cell in the right click 'master' table. The blue outline of the right click 'master' table shows where I would like the terrain menu.
Jar: http://www.mediafire.com/download/9wrrws8y6grrq6y/testGame.jar Source: http://www.mediafire.com/download/hi93aqocpnd8lff/testGame.7z
Entities can be selected via keys 1-3 and placed

Any help on how to re-align the cell to the right would be appreciated, thanks Smiley
4  Game Development / Newbie & Debugging Questions / Re: libGDX - renderer lag on: 2013-05-11 19:35:01
thanks cero. I changed:
1  
2  
renderer.getCamera().position.set(renderer.getCamera().position.x+velocity.x*Gdx.graphics.getDeltaTime()*80f, renderer.getCamera().position.y+velocity.y*Gdx.graphics.getDeltaTime()*80f, 0);
renderer.getCamera().update();

to:
1  
2  
renderer.getCamera().position.set(renderer.getCamera().position.x+velocity.x, renderer.getCamera().position.y+velocity.y, 0);
renderer.getCamera().update();

And now things are running smoothly Smiley.
I have worked through the new bostons tutorials and read a fair bit on delta timing as it was something I was having trouble understanding initially but in this case I was trying to use gdx's inbult getDelta function which I'm not sure of how well made it is. This is something I have been googling about for as I thought it was odd I didnt have to construct a game loop with delta timing in the tutorials. Is a game loop is supposed to be constructed in Gdx or does something like this:
1  
2  
3  
4  
   public void render(float delta) {      
      renderer.render();
      world.update();
   }

in the gameScreen suffice? Could this be done more efficiently/effectively?
5  Game Development / Newbie & Debugging Questions / Re: libGDX - renderer lag on: 2013-05-11 15:42:01
This will be an rts style game so there will be no central character to centre on, rather the player freely moves the camera around the map and starts at (0,0).
The default window size is 800x600 and the cameras width, height is 480x320 and Im using:
1  
2  
batch = new SpriteBatch();
batch.setProjectionMatrix(cam.combined);

Im still using this from the tutorial I was following by dustin reily and I think it scales, am I correct?

EDIT: after some reading about resolutions and aspect ratios I think that maybe the window and camera scaling at different aspect ratios may be the problem. Im taking a break and will test this later. Any info still appreciated
6  Game Development / Newbie & Debugging Questions / Re: libGDX - renderer lag on: 2013-05-11 15:32:44
thanks jimmt but I understand how the flow/separation should be, the problem Im having is that when I move the camera say two key presses(eg, one key press move the camera, cam.x + 5px*delta*80) in a direction, the renderer seems to only be rendering every 2nd frame, making it seem like things are jittery/jumping/expanding-shrinking.
7  Game Development / Newbie & Debugging Questions / Re: libGDX - renderer lag on: 2013-05-11 14:56:06
By that I mean that when the camera is moved with wsad there is a jitter/delay when image are rendered in the render method being called. In saying I think the problem may be with the world.update taking too long
8  Game Development / Newbie & Debugging Questions / libGDX - renderer lag on: 2013-05-11 14:31:25
hi
I've been getting back into java development after a break due to a new job and other things and decided to learn to use the gdx library rather than do what I think might be a common newbie thing and try and reinvent the wheel like I was trying to.
Anyway, I followed a tutorial series on youtube and have been working using the code from that series in a rts for the last week when I have the time. I have a few basic functions like building and tree placement and selection via number keys but I've been ignoring renderer lag/clipping while I work on these and would like to fix this before I go any further but I have no idea what the problem is. I have tried to move the camera adjustment and cam.update from the renderer render method to the world update method to separate the logic from the render loop but that didnt fix it.
If someone could help me out it would be much appreciated Smiley

http://www.mediafire.com/?61p4q3wvnzoc4c0
9  Game Development / Newbie & Debugging Questions / Re: checking for variable type on: 2012-11-23 01:50:26
Ah great. Thanks for that, that was exactly what I was after
10  Game Development / Newbie & Debugging Questions / checking for variable type on: 2012-11-23 01:23:58
Hey all
I was wondering if there was any way to have a constructor take a variable with an ambigious type and check its type via if statment. Here's the pseudo of what I mean:

drawStuff(Graphics g, Type s){
c;
if(s.getType==Canvas){
c.setType(s)
}elseif(s.getType==Window){
c.setType(s)
}else{print.out('unrecognized type')}
//draw stuff using c}

I guess I could pass in a string with 'Canvas' or 'window' and check that with the if statement but I as wondering if there was a built in way of doing this that is maybe a little more efficient.
Thanks in advance
11  Game Development / Newbie & Debugging Questions / Re: Pongclone - constructive criticism please on: 2012-11-13 13:35:10
Possibly but as I have just finished working through learning the basics of java and some other tutorials I was more after advice on code structure, anything that could be done better or more efficently, getting help problem solving etc etc. Newbie stuff.
I have no plans for this beyond adding in the ability to toggle between window modes and thought some other newbies might like to check out the code. I have been collecting any other java game source code other people have put out to learn from and either couldn't find much in the way of basic(pong, mario, tetris, pacman) beginner level game source available or had to do alot of digging to find it.
   
12  Game Development / Newbie & Debugging Questions / Re: Pongclone - constructive criticism please on: 2012-11-13 13:17:59
I hadn't uploaded the new source at that time. new source is up for windowed mode. I have implemented matheus's random code but thats about as much work I'm going to do on the randomness of the ball.
The last thing I'm doing with this before I move onto a new project is to bind the window switching to the F3 key which has been giving me troubles. I'm having trouble cleanly killing the windowed canvas and launching fullscreen during the game. I'm trying to do this by just toggling the windowedMode boolean but I have a feeling it's either not switching fast enough, which doesn't sound likely, or there's something else happening but I'm just too tired and aren't picking up on it.
13  Game Development / Newbie & Debugging Questions / Re: Pongclone - constructive criticism please on: 2012-11-13 09:56:10
@master: not sure if you are being serious or not but just to clarify I was saying 'oops' as in 'oh no I made a mistake'.

On another note, I have fixed switching between windowed and fullscreen. Embasassing mistake where I didn't rename some constructors in the draw method. It was still trying to get the fullscreen window height/width and not the canvas  Roll Eyes
Will upload the new source later.
14  Game Development / Newbie & Debugging Questions / Re: Pongclone - constructive criticism please on: 2012-11-12 09:49:51
Just an update.
I have been working today to add the option to switch between full screen and windowed mode. I think I am almost there as I can successfully switch between the two(via windowedMode boolean in ScreenManager, not ingame yet though I will bind setWindowedMode() to F3 or something later) but I am having issues with updating the canvas. I am not sure if this is an issue with my buffer strategy but I think I have narrowed it down to somewhere in getGraphics() or the ScreenManager update() method.
I have a feeling that Canvas buffering doesn't work the same way as Window buffering but maybe I'm wrong, I don't know a whole lot about Canvas or even Window at this point.
If someone would be so kind as to have a look at my code and help me out it would be much appreciated.
The new link is in the OP.
15  Game Development / Newbie & Debugging Questions / Re: Pongclone - constructive criticism please on: 2012-11-11 09:58:44
@master oops. I forgot to mention that. Just made the actual main pong class today and that's right off the end of bucky's tutorials, so I don't know enough to implement Ai and I don't want the 2nd paddle to just follow the ball exactly. Might as well not even have it Tongue

@matheus I made the mainPong class today and used the other classes from bucky's tutorials, with some modification(which is where that sync in draw comes from, wasn't sure if I should keep or discard it. From what I understand it has to do with letting a particular thread do its thing before allowing others to run(?)).
I have started reading killer game programming in java and used neither its nor bucky's loops, instead using the variable timestep loop from the game loops post in the articles section of this forum.
Thanks for that random function. I think I will use that as I didn't know it could randomize booleans.
16  Game Development / Newbie & Debugging Questions / Pongclone - constructive criticism please on: 2012-11-11 08:15:03
Hi all
I've been lurking around for quite a while whilst learning the basics of java and have just finished thenewbostons java game dev tuts and made a pong clone earlier today. Attached is both the runnable .jar, which starts in fullscreen, and the source.
Any constructive criticism or pointers would be much appreciated.
Known issue: pressing space while ball is moving will re-randomize ball velocity(direction).

Fullscreen Mode: http://www.mediafire.com/?98qobp777zf6jrb,22qohsmvefvnif8

EDIT: Windowed mode version(working): http://www.mediafire.com/?c7sg1cvft9qe47j,d2yeaa1lqihxfhs

enjoy,  
Ado
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (66 views)
2014-11-26 15:22:04

toopeicgaming1999 (58 views)
2014-11-26 15:20:36

toopeicgaming1999 (12 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (28 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (76 views)
2014-11-13 12:34:49

digdugdiggy (53 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!