Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 26, 2013 1:38 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Jul 22, 2012 7:59 pm 
Offline
User avatar

Joined: Wed Jun 20, 2012 8:10 pm
Posts: 54
Hi guys!

I'm trying to do a simple drag/drop kind of thing.
I overrided the mouseDragged method, and do the x += newx - oldx;

The problem is, the mouseDragged is actually called several times on the same x;y :

From : 578;235 to 579;236
New location : 321;201
From : 578;235 to 579;236
New location : 322;202
From : 579;236 to 583;237
New location : 326;203
From : 579;236 to 583;237
New location : 330;204
From : 583;237 to 590;237
New location : 337;204
From : 583;237 to 590;237
New location : 344;204
From : 590;237 to 594;238
New location : 348;205
From : 590;237 to 594;238
New location : 352;206
From : 594;238 to 598;238
New location : 356;206

I'm assuming it's a bug, but i don't want to post one topic each day on the bug section, i would like to know if this is normal? :)
If it is, how the hell am i supposed to implement this??

_________________
Seventeen


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 8:02 pm 
Offline
User avatar

Joined: Wed Jun 20, 2012 8:10 pm
Posts: 54
If i consume the event apparently, it's working.
Why do I have to do this? (Moreover i would have to save the GameContainer in a variable to be able to consume the event... Not very clean)

_________________
Seventeen


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 8:56 am 
Offline
User avatar

Joined: Tue Jul 17, 2012 11:27 am
Posts: 62
I think it is a bug. Today I wanted to ask the same question, but I saw you posted already. You can write a workaround with mousepressed, mousemove and mouse up but it is very dirty.

EDIT: What do you mean with this:
Quote:
If i consume the event apparently, it's working.
?
I don't know if it's my english or you sentence which causes the problem :D

_________________
Open source isometric engine made with slick: http://wurfelengine.net


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 10:11 am 
Offline
User avatar

Joined: Wed Jun 20, 2012 8:10 pm
Posts: 54
You can get the GameContainer in your class, for example in the init or enter do something like :

Code:
GameContainer thisgc;

public void enter(GameContainer gc, StateBasedGame game)
            throws SlickException {
thisgc = gc;
...
}


then on your mouseDragged do something like :

thisgc.getInput().consumeEvent();

It should solve the problem (then again it's also pretty dirty imo)

_________________
Seventeen


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

All times are UTC


Who is online

Users browsing this forum: No registered users 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