Page 1 of 1
Move multiple graphical objects
Posted: Sun Oct 19, 2008 8:50 pm
by jeffInt
If I have a couple of oval objects on a card in my mainstack and I place the following code in a button also on this card;
on mouseUp
set the lockMoves to true
move graphic "myOval" to random(400),random(400) in random(3) seconds
move graphic "myOval1" to random(400),random(400) in random(3) seconds
set the lockMoves to false
end mouseUp
Why do the oval objects jump from one position to another instead of moving smoothly?
Any way of making multiple objects move slowly and concurrently?
Jeff
Posted: Sun Oct 19, 2008 10:17 pm
by gyroscope
Hi Jeff, my guess is that using lockMoves is causing the prob. Take the lockMove true and false out of the equation and it works OK.
Still leaves the problem of running at the same time. I would think you need something like the code below:
Code: Select all
on mouseUp pMouseBtnNo
hereWeGo
end mouseUp
on hereWeGo
put random(400) into tUp
put random(400) into tLeft
put random(3) into tSecs
set the location of graphic "MyOval" to tUp, tLeft --in tSecs seconds
put random(400) into tUp
put random(400) into tLeft
put random(3) into tSecs
set the location of graphic "MyOval1" to tUp, tLeft --in tSecs seconds
send hereWeGo to me in 120 milliseconds
end hereWeGo
Still leaves your problem of moving it over the time period; I'm a bit tired and pushed for time to work it out at the moment but I'm certain someone else will gladly supply this addition to the above code (if they think it's the correct way to go about this!

)
Hope I've been of
some help...

Posted: Sun Oct 19, 2008 11:30 pm
by bn
Hi Jeff,
Code: Select all
on mouseUp
set the lockmoves to true
move graphic "myOval" to random(400),random(400) in random(3) seconds without waiting
move graphic "myOval1" to random(400),random(400) in random(3) seconds without waiting
set the lockmoves to false
end mouseUp
This works for me, the trick is the without waiting
cheers
bernd
Posted: Sun Oct 19, 2008 11:48 pm
by gyroscope
Jeff,
Hope I've been of some help...
Ah well, I wasn't but I tried!

I've learned from Bernard here as well, excellent. If it's OK, I wish to ask Bernard a couple of questions via your thread....
Hi Bernard
I tried a second button to move a third object; clicking one straight after the other, I was really pleased to see that they all moved at the same time.
So this would seem to be a suitable and perfectly reasonable substitute for a
Code: Select all
send "SuchandSuch" to me in --so many -- milliseconds
type code
Is that correct? Could I activate say, 30 graphics at the same time from multiple handlers from different scripts, and they'd all move smoothly at the same time?
And secondly, could one weave in animation using move without waiting i.e loop through 10 frames, for instance, could you tell me, please? (My gut instinct tells me the answer is going to be no but I hope I'm wrong!)

Posted: Mon Oct 20, 2008 12:07 am
by bn
Hi Gyroscope,
s that correct please? Could I activate say, 30 graphics at the same time, and they'd all move smoothly at the same time?
I do it with up to 30 graphics at the same time, depending what you let them move by it is fairly smooth or in some cases (I let them move along the points of a graphic) if there are many points lets say more than 60 with long distances in between it starts to get jerky.
So for most things you can move quite some number of objects with this and have a nice performance. This is on a mac intel 2.2 GHz, obviously if you use a slower processor it might be less objects. So if you want to start many object with different trajectories and travel time it is a viable way.
But really Malte is the ultimate reference all things Animation.
cheers
Bernd
Posted: Mon Oct 20, 2008 1:00 am
by gyroscope
Thanks for the reply, Bernard. Sounds good, I'll experiment further with move without waiting some time soon.
But really Malte is the ultimate reference all things Animation.
Yes, he certainly is, I have a copy of the excellent Animation Engine but haven't used it much (um, actually, haven't used it at all yet!) but I will when the muse tells me to jump to my adventure game I hope to write some day.
I wonder if there is any info/practical examples on how to weave in animation code into any of the AE handlers/functions (i.e animation on the move travelling in a circle, or ellipse, for instance), also with info about timing?
Apologies Jeff, if it seems like I'm taking over your thread; thank you.

Posted: Mon Oct 20, 2008 5:54 pm
by jeffInt
Thank you all for your help. The "without waiting" seems to work a treat.
Jeff