moving objects
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
moving objects
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
This came up in another thread too. Besides setting acceleratedRendering, you also need to set the layerMode of each block to "dynamic".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Re: moving objects
Thanks for the response. I already had the layerMode of each block set to "dynamic".jacque wrote: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
It may be in your script then. Does the handler include any "wait" instructions?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Re: moving objects
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.
- Attachments
-
- gammeeee111.zip
- (2.09 KiB) Downloaded 334 times
Re: moving objects
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: moving objects
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.
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Re: moving objects
Here is the relevant part of the codejacque 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.
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.
- Attachments
-
- Untitled 1.zip
- (212.35 KiB) Downloaded 274 times
Re: moving objects
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:
Not sure if that will help on your device, the motion was smooth either way on my Android.
Simon
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
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Re: moving objects
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 ?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:Not sure if that will help on your device, the motion was smooth either way on my Android.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
Simon
Re: moving objects
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.
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Re: moving objects
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 :/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.
Re: moving objects
I'm still thinking you'll have to use the "move" command, it's very smooth.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 :/
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: moving objects
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
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
- Attachments
-
- MovingonAndroid.zip
- (2.68 KiB) Downloaded 278 times
Re: moving objects
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.
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com