Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  UiButton events  (Read 2291 times)
0 Members and 1 Guest are viewing this topic.
Offline tomcat

Senior Newbie




Java games rock!


« Posted 2005-01-22 14:15:14 »

I have looked around to figure out how to detect when a UiButton is pressed. Does anybody know of an example or how this is done?
tomcat
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #1 - Posted 2005-01-22 15:50:22 »

During an update call it checks the input object that you set during it creation. If it is "hit" it calls any actions you set the the object. See jmetest.ui.TestUI.

Don't send a man to do a monkey's work.
Offline tomcat

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-01-23 15:23:30 »

Not sure if I got this right. Created a couple of UiButtons and added them to a node and attached to the rootNode which is updated every cycle. Created a InputHandler but dont seem to figure out how to catch the button press event from the buttons (you can catch KeyBoardActions which is not the same).

I created an AbsoluteMouse and set the cursor etc and then added that to the InputHandler but cant see the mouse either.

Any ideas where to go next?
tomcat
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline winkman

Senior Newbie




Java games !


« Reply #3 - Posted 2005-01-24 06:00:50 »

from a quick view into the code it seems that the UIButton gets a reference to the inputSystem at creation.

then at runtime UIButton.update(float) is called each logic cycle.

The key however seem to lie in the mouse - setup:


/*
        * The absolute mouse
        */
       mouse = new AbsoluteMouse("Mouse Input", display.getWidth(), display
               .getHeight());
       TextureState cursor = display.getRenderer().createTextureState();
       cursor.setEnabled(true);
       cursor.setTexture(TextureManager.loadTexture(TestAbsoluteMouse.class
               .getClassLoader()
               .getResource("jmetest/data/cursor/cursor1.png"),
               Texture.MM_LINEAR, Texture.FM_LINEAR, true));

       /*
        * Add the cursor texture to the mouse
        */
       mouse.setRenderState(cursor);
       /*
        * Add the alpha state to the mouse
        */
       mouse.setRenderState(as2);
       mouse.setMouseInput(InputSystem.getMouseInput());

       /*
        * Set the speed of the mouse
        */
       mouse.setSpeed(2.0f);
       /*
        * Set the mouse that the inputHandler is using so the UIObjects can
        * retrieve it
        */
       input.setMouse(mouse);


hth
Martin

Pages: [1]
  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.

BurntPizza (13 views)
2014-09-19 03:14:18

Dwinin (31 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (79 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (62 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (36 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
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!