Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jun 20, 2013 12:06 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon Jul 09, 2012 9:46 pm 
Offline
User avatar

Joined: Wed Jun 20, 2012 8:10 pm
Posts: 54
Hello guys, I have a weird behaviour on a keypress and was wondering if this is normal.

I overrided the function keypress in a BasicGameState class like this :

Code:
public void keyPressed(int key, char c) {
      
      System.out.println("here"+key+"---"+c);
      
   }


It goes ok, when i press right for example i can see on the console : here205---
When i put some code like this :

Code:
public void keyPressed(int key, char c) {
      
      System.out.println("here"+key+"---"+c);

if (index == 0){
         index = mylist.size()-1;
      }
      else{
         index--;
      }
      if (mylist.size() > 0){
         mycomponent = new MyComponent(thisgc,null,300,100);
      }
      else{
         mycomponent = null;
      }
      
   }


The code not even testing on the input or anything event related, the function goes berserk and outputs indefinetly :here205---

When i consume the event : thisgc.getInput().consumeEvent();
It's working as it should.
I don't understand why i have to use this workaround, and why the event is fired again and again (i only press the key once)

_________________
Seventeen


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group