Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Implementing a decent GUI  (Read 4449 times)
0 Members and 1 Guest are viewing this topic.
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #30 - Posted 2012-10-18 16:18:56 »

For what it's worth:
Screen.java
Area.java

Cas Smiley

But... But... STATIC... Sad

Anyway, still have to say, that I enjoyed the RotT source Grin

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Ultroman

JGO Knight


Medals: 25
Projects: 1


Snappin' at snizzes since '83


« Reply #31 - Posted 2012-10-20 00:28:18 »

Actually, forget what I said. scene2d is awesome! Cheesy
I've played around with it a bit now, and with very little effort, you can create your own UI elements, and if you need to create dynamic boxes and such, it is easily extendible.

I only need to get a better understanding of the action-system. I'm having trouble triggering things, but it's probably just something I've missed.

- Jonas
Offline Nate

JGO Kernel


Medals: 149
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #32 - Posted 2012-10-20 00:47:13 »

Woohoo! Cheesy

Actions are described here:
https://code.google.com/p/libgdx/wiki/scene2d#Actions
Let me know which of that is confusing and maybe we can reword things. In a nutshell, there is a simple action class then a few convenience base classes for different action types (eg TemporalAction for stuff that happens over time, etc), then built on top those are a number of common action classes. You can create instances of those yourself, but to make using those more convenient, there is the "Actions" class which has static methods to get configured, pooled action instances.

It is most common and convenient to use the "Actions" class to get instances for sequence, parallel, delay, fade, etc but also keep in mind you can create your own actions. Eg, it is common to extend TemporalAction and implement the begin, update, and/or end methods to do whatever you want. Note to avoid GC you probably want to use Actions.action(Class) to easily get a pooled instance of your action. It will be put back in the pool automatically when it is no longer needed. Lastly, here is an easy way to run some code after some actions:

1  
2  
3  
4  
5  
6  
7  
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
...
sequence(someAction1, someAction2, run(new Runnable() {
   public void run () {
      // some code
   }
}));

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ultroman

JGO Knight


Medals: 25
Projects: 1


Snappin' at snizzes since '83


« Reply #33 - Posted 2012-10-20 01:29:04 »

Woohoo! Cheesy

Actions are described here:
bla bla bla VERY NICE STUFF bla bla bla
Thanks a lot for that!
What I was pondering was how hard it would be to do something like this:
- I click a button on my stage (like "Start Game")
- Then I activate some actions that makes the entire stage fade out
- Then only when the fade-out is complete, does it start the game

How do you intend one does that with your system? If you would be so kind as to maybe just explain in short pseudo-steps, sort of like:
- Make a boolean in your stage
- Use a listener and @Override touchUp to change the boolean
- (somehow) apply an action that fades out the entire stage
- Change to game-screen

EDIT: Oh, wait...I see. You already said that. run() Cheesy
EDIT 2: Dude, this is AWESOME! I'm so sorry I compared this to Swing. I mean...it's...I'M SO SORRY!

- Jonas
Offline Nate

JGO Kernel


Medals: 149
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #34 - Posted 2012-10-20 01:46:16 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
TextButton button = new TextButton("Some Text", skin);
button.addListener(new ChangeListener() {
   public void changed (ChangeEvent event, Actor actor) {
      stage.getRoot().addAction(sequence(fadeOut(4), run(new Runnable() {
         public void run () {
            // start game
         }
      })));
   }
});


You can get the stage from a field on your class, or event.getStage(), or actor.getStage(), or button.getStage().

EDIT 2: Dude, this is AWESOME! I'm so sorry I compared this to Swing. I mean...it's...I'M SO SORRY!
LOL  Grin

Offline Ultroman

JGO Knight


Medals: 25
Projects: 1


Snappin' at snizzes since '83


« Reply #35 - Posted 2012-10-20 02:01:43 »

I tried copying your code exactly, and I got the same "problem" I got before. It doesn't want to accept the run(new Runnable(){summat};
"run" gives an error saying: "The method run(new Runnable(){}) is undefined for the type new ChangeListener(){}"

I'm guessing this is because I've cocked something up while setting up my stages or something. It works fine if I just put Actions.run(){summat};
Does this matter?

Once again, you were very right. After climbing that first hump, it's like "Aaaah, where has this been all my life!?"

- Jonas
Offline Nate

JGO Kernel


Medals: 149
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #36 - Posted 2012-10-20 02:02:56 »

Missing static import?
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;

Offline Ultroman

JGO Knight


Medals: 25
Projects: 1


Snappin' at snizzes since '83


« Reply #37 - Posted 2012-10-20 02:04:57 »

Missing static import?
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
*Major facepalm*
Of course...

*runs along with his new toy*

<3 libgdx <3

- Jonas
Offline sproingie

JGO Kernel


Medals: 202



« Reply #38 - Posted 2012-10-20 07:38:25 »

Yeah the thing to remember in stage2d is that actions are run in parallel unless you explicitly sequence them otherwise -- every action means "start doing this NOW".  There is a convenience action now for scheduling actions "after everything else is done" though this can get interesting if you have two of them scheduled (I never did chance to try that scenario)

It's definitely something quite different than what is normally meant by an Actor system, that's for sure.  But damn is it a lot of fun to play with.
Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (39 views)
2014-10-17 03:59:02

Norakomi (30 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (57 views)
2014-10-14 00:39:48

TehJavaDev (58 views)
2014-10-14 00:35:47

TehJavaDev (48 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
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!