Skip to main content

Pointer Dragged

9 replies [Last post]
pabloma2002
Offline
Joined: 2011-08-27
Points: 0

Is it possible to overwrite the pointerdragged method so as to use foats instead of integers? If so, how?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

No.

Why would you require something like that?

Floats make sense when you need to draw based on subpixel coordinates which LWUIT tries to abstract away. When porting to platforms that deliver events as floats we just round to the nearest integer.

pabloma2002
Offline
Joined: 2011-08-27
Points: 0

I need two objects to move at the same time, but the B object has to move 1.5 times the distance the A object has moved, and I want a steady motion. If not floats, doubles may do.

vprise
Offline
Joined: 2003-11-07
Points: 0

You don't need floats for drawing on the screen for this purpose, it would just slow you down.

Look at LWUIT's list scrolling which is pretty smooth on reasonably performant devices. We use floating point arithmetics for the Motion class yet when it comes time to choosing a pixel we round to the nearest integer position.

You should only use floating point drawing primitives when dealing with graphics that neads features such as anti-alising or view neutrality.

pabloma2002
Offline
Joined: 2011-08-27
Points: 0

Sorry, but I need at least one decimal.

vprise
Offline
Joined: 2003-11-07
Points: 0

Drawing with floating point values is SLOW. VERY SLOW.

Even if it were supported in LWUIT you shouldn't do this.

You can store positions in floating point values (that is what we do, e.g. in class motion) but there is absolutely no reason whatsoever to DRAW the positions using floating point values. The difference will not be noticeable even on a 4 inch device while the performance will be horrible.

pabloma2002
Offline
Joined: 2011-08-27
Points: 0

Let's see if I explain myself better. When object A.X (the one that gets the getX position) equals 1, object B.X should be 2, and when A.X is 2, B.X should be 4. But what happens when I want B.X to equal 3? I need A.X to be 1.5.

vprise
Offline
Joined: 2003-11-07
Points: 0

It doesn't matter.

A difference of a single pixel rounded up or down will hardly be noticeable to the eye.

To shift the objects you can use floats all you want just round them when setting the X and Y.

pabloma2002
Offline
Joined: 2011-08-27
Points: 0

Once again, let's see if I explain myself better. I've already tried this midlet in my mobile and it "is" noticeable. So if what I'm trying to do is not noticeable, I will simply drop the project. But if anyone can think of a workaround, I would be glad to hear it.

Thanks.

pabloma2002
Offline
Joined: 2011-08-27
Points: 0

Does anyone at leat know how the pointer dragged function works, to see if I can create a similar one instead of overriding it?