Page 1 of 1

How to make this move smoothly?

Posted: Thu Apr 11, 2013 6:38 pm
by ahmedinvent24BUSGdU9
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.

Re: How to make this move smoothly?

Posted: Thu Apr 11, 2013 6:53 pm
by asayd
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

Re: How to make this move smoothly?

Posted: Thu Apr 11, 2013 8:12 pm
by ahmedinvent24BUSGdU9
Thank You Devin for your help :D

But where is the acceleratedRendering ??

Ahmed

Re: How to make this move smoothly?

Posted: Thu Apr 11, 2013 8:47 pm
by sturgis
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.

Re: How to make this move smoothly?

Posted: Thu Apr 11, 2013 8:48 pm
by asayd
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

Re: How to make this move smoothly?

Posted: Thu Apr 11, 2013 8:54 pm
by ahmedinvent24BUSGdU9
Thanks, Sturgis, Asayd
For your Help :D

Regards
Ahmed F.