How to make this move smoothly?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ahmedinvent24BUSGdU9
Posts: 43
Joined: Mon Oct 15, 2012 6:44 pm

How to make this move smoothly?

Post by ahmedinvent24BUSGdU9 » Thu Apr 11, 2013 6:38 pm

Hello :)

This is the code of side scrolling, when I run it on the mobile devices it's moving not smoothly :(

Code: Select all

on updateScreen

      
   if sGameRunning then
      playRocket
      set the left of img "bg1" to (the left of img "bg1" - 25)
      set the left of img "bg2" to (the left of img "bg2" - 25)
      set the left of img "bg4" to (the left of img "bg4" - 25)
      set the left of img "bg5" to (the left of img "bg5" - 25)
      set the left of img "bg6" to (the left of img "bg6" - 25)
      set the left of img "bg7" to (the left of img "bg7" - 25)
      set the left of img "bg8" to (the left of img "bg8" - 25)
   end if
   
   if the right of img "bg1" < 0 then 
      set the bottomLeft of img "bg1" to the bottomRight of img "bg2"
   end if
   
      if the right of img "bg2" < 0 then 
      set the bottomLeft of img "bg2" to the bottomRight of img "bg1"
   end if
   
         if the right of img "bg4" < 0 then 
      set the bottomLeft of img "bg4" to the bottomRight of img "bg2"
   end if
   
          if the right of img "bg5" < 0 then 
      set the bottomLeft of img "bg5" to the bottomRight of img "bg4"
   end if
   
             if the right of img "bg6" < 0 then 
      set the bottomLeft of img "bg6" to the bottomRight of img "bg5"
   end if
   
          if the right of img "bg7" < 0 then 
      set the bottomLeft of img "bg7" to the bottomRight of img "bg6"
   end if
   
        if the right of img "bg8" < 0 then 
      set the bottomLeft of img "bg8" to the bottomRight of img "bg1"
   end if
   
   
end updateScreen


How to make it move smoothly?
Please Help :)

Thanks

Ahmed F.

asayd
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 107
Joined: Mon Apr 10, 2006 7:02 pm
Location: Provo, Utah, USA
Contact:

Re: How to make this move smoothly?

Post by asayd » Thu Apr 11, 2013 6:53 pm

Ahmed,

Are you using the game loop handlers from the Game Academy? I think your increment may be too high. Try using a smaller increment, maybe 5 to 10, and a higher refresh rate.

Also, make sure that you set the acceleratedRendering of the stack to true on the card doing the scrolling. And make sure that the layerMode of each moving object is set to "dynamic".

Devin
Devin Asay
Learn to code with LiveCode University
https://livecode.com/store/education/

ahmedinvent24BUSGdU9
Posts: 43
Joined: Mon Oct 15, 2012 6:44 pm

Re: How to make this move smoothly?

Post by ahmedinvent24BUSGdU9 » Thu Apr 11, 2013 8:12 pm

Thank You Devin for your help :D

But where is the acceleratedRendering ??

Ahmed

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to make this move smoothly?

Post by sturgis » Thu Apr 11, 2013 8:47 pm

In the handler where you start your game loop, put the code

set the acceleratedrendering of this stack to true
If you're using the code from the game academy, its probably already in there somewhere, but I don't recall exactly where. Either way, do make sure its set to true before you start moving things about.

And for each object as mentioned, you'll want to set the layermode to dynamic. If you are cloning/copying your images/buttons/whatever you're moving you can set the layermode of the template object you are cloning from to dynamic and then any cloned objects will also be set to dynamic.

asayd
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 107
Joined: Mon Apr 10, 2006 7:02 pm
Location: Provo, Utah, USA
Contact:

Re: How to make this move smoothly?

Post by asayd » Thu Apr 11, 2013 8:48 pm

There is no GUI for setting acceleratedRendering, just do it in a script before the motion begins. For instance you could do this in the card script:

Code: Select all

on preOpenCard
  set the acceleratedRendering of this stack to true
end preOpenCard
Cheers,
Devin
Devin Asay
Learn to code with LiveCode University
https://livecode.com/store/education/

ahmedinvent24BUSGdU9
Posts: 43
Joined: Mon Oct 15, 2012 6:44 pm

Re: How to make this move smoothly?

Post by ahmedinvent24BUSGdU9 » Thu Apr 11, 2013 8:54 pm

Thanks, Sturgis, Asayd
For your Help :D

Regards
Ahmed F.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”