Trouble with graphics display in OS X
Scott Rossi
scott at tactilemedia.com
Wed Jan 12 13:18:55 EST 2005
Recently, James Hurley wrote:
>> on mouseUP
>> set the loc of grc "ball" to 100, 100
>> put .1 into dx
>> put .1 into dy
>> put the loc of grc "ball" into tBallLoc
>> repeat 5000
>> add dx to item 1 of tBallLoc
>> add dy to item 2 of tBallLoc
>> set the loc of grc "ball" to tBallLoc
>> --wait 1 millisec
>> end repeat
>> set the loc of grc "ball" to 100,100
>> end mouseUP
>> In OS 9, this causes the ball graphic to slide smoothly along a 45
>> degree line. In OS X the ball moves erratically to two or three spots
>> on the line and then quickly back to the starting location.
>>
>> (Since the loc consists only of integers, this should move the ball
>> smoothly through points 100,100 to 101,101 to 102,102 ... 600,600.)
>>
>> If I insert the "wait 1 millisec" the motion is smooth, but slow. It
>> takes, of course, 5 seconds plus.
>>
>> Is this a known problem in OS X?
>>
>> I am running RR 2.2.1 and OS X 2.3 on a PowerBook G4
It's not a problem, it's the fact that Rev is moving the ball so quickly,
there's not enough time to render the results to the screen.
And Bill Griffin is right: you can only position objects to the nearest
pixel, nothing less, so simply changing the original code by 1 decimal place
fixes the problem:
on mouseUP
set the loc of grc "ball" to 100, 100
put 1 into dx
put 1 into dy
put the loc of grc "ball" into tBallLoc
repeat 500
add dx to item 1 of tBallLoc
add dy to item 2 of tBallLoc
set the loc of grc "ball" to tBallLoc
wait 1 millisec
end repeat
set the loc of grc "ball" to 100,100
end mouseUP
If you remove the "wait" instruction, again, the ball moves so fast you
can't see it. Look at increasing the the dx and dy values to get even
faster performance. And see the following example for some more clues. In
your message enter:
go url "http://www.tactilemedia.com/download/bouncer.rev"
Raymond E. Griffith wrote:
> you might want to look at the drag command.
>
> set the dragspeed to 500
> drag grc "ball" from 100,100 to 600,600
>
> And then there is the "move" command:
>
> move graphic "ball" to the points of graphic "path"
>
> "move" also has an appropriate movespeed you can set.
>
> Your difficulty is that you are trying too hard, and you are making the
> objects do too much work. While OS X does have graphics difficulties that OS
> 9 does not, physically setting each movement consumes a lot of resources.
Here's another opinion:
Setting the position of objects via a repeat or send loop will often times
look *better* than move or drag, so don't rule out this technique outright
without trying it in your situation. I've noticed better performance by
manually setting object position, even if at the expense of system
resources.
Rev is actually pretty good at moving things around the screen -- it just
gets tricky when you need to move many things...
Regards,
Scott Rossi
Creative Director
Tactile Media, Development & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com
More information about the use-livecode
mailing list