Page 1 of 1
moving objects
Posted: Thu Apr 24, 2014 11:36 pm
by ferhan24badshah
I have 3 blocks evenly spaced out on the card. I animated each of the blocks to move from right to left at the same speed, and if the right side of a block moves past the left side of the card, the left side of the block is placed past the right side of the card and it continues its motion towards the left again. The animation looks fine on LiveCode but when I package it into my phone, the animation appears very laggy and slows down frequently. I also set the acceleratedrendering to true in preopencard.
Re: moving objects
Posted: Sat Apr 26, 2014 6:08 am
by jacque
This came up in another thread too. Besides setting acceleratedRendering, you also need to set the layerMode of each block to "dynamic".
Re: moving objects
Posted: Sat Apr 26, 2014 9:20 pm
by ferhan24badshah
jacque wrote:This came up in another thread too. Besides setting acceleratedRendering, you also need to set the layerMode of each block to "dynamic".
Thanks for the response. I already had the layerMode of each block set to "dynamic".
Re: moving objects
Posted: Sat Apr 26, 2014 10:45 pm
by jacque
It may be in your script then. Does the handler include any "wait" instructions?
Re: moving objects
Posted: Sun Apr 27, 2014 6:40 am
by ferhan24badshah
jacque wrote:It may be in your script then. Does the handler include any "wait" instructions?
Here is my code....It's really laggy and the bottom obstacles aren't moving at the same pace as the top obstacles.
Re: moving objects
Posted: Mon Apr 28, 2014 6:56 pm
by jacque
Could you post just the relevant part of your script please? I rarely download whole stacks, they are too time-consuming to read and debug. Short handler excerpts are much better for me.
Re: moving objects
Posted: Mon Apr 28, 2014 8:30 pm
by magice
Actually this runs fine in windows, however it does not completely shut down. You need to add a script on closeStack that deletes all pending messages. I have no idea if that could be causing your problem since I have no experience with phone apps, (maybe multiple instances running on the phone?) but it still should be taken care of.
Re: moving objects
Posted: Tue Apr 29, 2014 1:25 am
by ferhan24badshah
jacque wrote:Could you post just the relevant part of your script please? I rarely download whole stacks, they are too time-consuming to read and debug. Short handler excerpts are much better for me.
Here is the relevant part of the code
command moveObj
....if the hilite of button "check" is true then
.........set the left of the image "brick1" to the left of image "brick1" - 10
.........set the left of the image "brick2" to the left of image "brick2" - 10
.........if the right of the image "brick1" < 0 then
..............set the left of the image "brick1" to the right of this card
.........end if
.........if the right of the image "brick2" <0 then
.............set the left of the image "brick2" to the right of this card
.........end if
.........send "moveObj" to me in 20 milliseconds
end moveObj
I tried using images instead of buttons but that didn't make a difference. It seems to run fine on Windows but on my android phone, the animation is really jerky.
I attached a more simple version of my project. The coding is in the card script.
Re: moving objects
Posted: Tue Apr 29, 2014 5:30 am
by Simon
Hi Ferhan,
Once on a real device "set the left..." or "set the loc..." of multiple objects gets very slow. I believe you are going to have to think up another way to do this.
In your demo for the motion you show, it could be just group the objects and "move" the group.
I just tried your last stack on my Kindle Fire and it's very smooth. You might try locking the screen:
Code: Select all
command moveObj
if the hilite of button "check" is true then
lock screen
set the left of the image "brick1" to the left of image "brick1" - speed
set the left of the image "brick2" to the left of image "brick2" - speed
if the right of the image "brick1" < 0 then
set the left of the image "brick1" to the right of this card
end if
if the right of the image "brick2" < 0 then
set the left of the image"brick2" to the right of this card"
end if
send "moveObj" to me in 20 milliseconds
unlock screen
end if
end moveObj
Not sure if that will help on your device, the motion was smooth either way on my Android.
Simon
Re: moving objects
Posted: Tue Apr 29, 2014 7:41 am
by ferhan24badshah
Simon wrote:Hi Ferhan,
Once on a real device "set the left..." or "set the loc..." of multiple objects gets very slow. I believe you are going to have to think up another way to do this.
In your demo for the motion you show, it could be just group the objects and "move" the group.
I just tried your last stack on my Kindle Fire and it's very smooth. You might try locking the screen:
Code: Select all
command moveObj
if the hilite of button "check" is true then
lock screen
set the left of the image "brick1" to the left of image "brick1" - speed
set the left of the image "brick2" to the left of image "brick2" - speed
if the right of the image "brick1" < 0 then
set the left of the image "brick1" to the right of this card
end if
if the right of the image "brick2" < 0 then
set the left of the image"brick2" to the right of this card"
end if
send "moveObj" to me in 20 milliseconds
unlock screen
end if
end moveObj
Not sure if that will help on your device, the motion was smooth either way on my Android.
Simon
thanks simon. i added the lock screen to my code and the animation appears to be more smooth now. I tried grouping and using the move command too. but the movement still seems to be jerky when the objects move out of the screen if my eyes aren't fooling me. Did you notice that ?
Re: moving objects
Posted: Tue Apr 29, 2014 4:36 pm
by jacque
Thanks for posting the script, it's easier for us that way and you'll get more replies too.
The grouping idea is a good one. You should change the layermode of the blocks back to static and set the layermode of the group to dynamic now. You want only the highest layer to be buffered. Having each object inside the group individually buffered can actually slow things down.
Re: moving objects
Posted: Fri May 02, 2014 11:12 pm
by ferhan24badshah
jacque wrote:Thanks for posting the script, it's easier for us that way and you'll get more replies too.
The grouping idea is a good one. You should change the layermode of the blocks back to static and set the layermode of the group to dynamic now. You want only the highest layer to be buffered. Having each object inside the group individually buffered can actually slow things down.
I've tried all of those ideas but it still causes the animation to be jerky especially when it goes into the left side of the screen on my phone :/
Re: moving objects
Posted: Fri May 02, 2014 11:18 pm
by Simon
ferhan24badshah wrote:
I've tried all of those ideas but it still causes the animation to be jerky especially when it goes into the left side of the screen on my phone :/
I'm still thinking you'll have to use the "move" command, it's very smooth.
Simon
Re: moving objects
Posted: Sat May 03, 2014 2:24 am
by sefrojones
Check out this little sample stack to show you how much more smooth it will be using the "move"command.
This stack basically moves 3 images down the card along a graphic line as a path. The lines are hidden. when the image goes off the edge of the card it is hidden, the path is randomly placed in a new spot and the image is moved again. I just created/ tested this stack on an ancient droid and it runs very smooth compared to doing the same thing with the "set" command.
Good Luck!
--Sefro
Re: moving objects
Posted: Sat May 03, 2014 6:22 am
by jacque
If you want to use the original script, try reducing the 20 milliseconds to 1, then tinker with the time delay to see what works.
But I agree "move" is better. You'll get a consistent animation no matter what the speed of the CPU. When you use "set" the time delay isn't calculated until after the blocks have finished moving, and that can take different amounts of time on different devices.