Page 1 of 1

scrolling background with gaps

Posted: Thu Dec 05, 2013 5:45 pm
by star0629
I want to delete this post

Re: scrolling background with gaps

Posted: Thu Dec 05, 2013 6:07 pm
by Klaus
Hi star0629,

hmm, maybe a "lock screen" might help?
And do not use THE when addressing objects:
BAD: left of THE image...
GOOD; left of image...

Try this:

Code: Select all

on moveBg
  lock screen
  
  ## use a repeat loop to save some typing :-)
  repeat with i = 1 to 3
    set the left of img ("bg" & i) to the left of img ("bg" & i) - 4
    
    if the right of img ("bg" & i) < 0 then
      set the left of img ("bg" & i) to 818
    end if
  end repeat
  
  ## DONE, lift curtain :-)
  unlock screen
  
  updateScore
end moveBg
Best

Klaus

Re: scrolling background with gaps

Posted: Sat Dec 07, 2013 4:29 pm
by star0629
nope that didn't work and the images continue to overlap each other :@ ...once they go the card they start again to the beginning position overlapped :/

Re: scrolling background with gaps

Posted: Sat Dec 07, 2013 6:01 pm
by dunbarx
Hi,

Where do the images start? Are their locs initialized?

I see no problems with your script, in that the three images move in lock-step as you ordered, reappearing at the right when they disappear off screen to the left. What "overlap" are you seeing? The images are, as I said, in lock-step.

Craig Newman

Re: scrolling background with gaps

Posted: Tue Dec 10, 2013 12:34 am
by star0629
The images are positioned at the front in the middle of the card e.g

"Image1" "Image2"

I dont code anything for the images to be in that certain location, i just happen to put them there and then lock the position when on edit mode. What i mean by over lap is when the game is running the images are scrolling along the card, once "image1" goes off the card (left side) it reappears from the right side of the card (here is when is begins to overlap) whilst "image1" is scrolling along as expected, "image2" has gone of the card (left side) and where there is supose to be a gap between the two images is filled up and the "image2" appears closer to "image1" as if "image2" is moving at a faster rate than "image1" this continues until "image2" has gone in front of "image1" somehow.

Could it possibly be becuase of the size of the image i am using? Do they all have to be same in length and height and stuff?

Thanks

Re: scrolling background with gaps

Posted: Tue Dec 10, 2013 12:41 am
by dunbarx
Have you locked the size of the images? This can cause problems, and has no bearing on their manipulation under script control.

Craig

Re: scrolling background with gaps

Posted: Tue Dec 10, 2013 12:43 am
by star0629
Yeah the lock size and position box is ticked on all the images

Re: scrolling background with gaps

Posted: Tue Dec 10, 2013 2:06 am
by Simon
Hi star0629,
From your block of code:

if the right of the image "bg1" < 0 then
set the left of the image "bg1" to "822" - 4
end if

Would it be more accurate to say

if the right of image "bg1" < 0 then
set the left of image "bg1" to the (right of image "bg3" - 4)
end if

That way it doesn't matter the size of your images and you don't have to rely on that 822.

Simon
Edit: dropped "the"

Re: scrolling background with gaps

Posted: Tue Dec 10, 2013 2:46 am
by dunbarx
Simon,

Have not looked at your idea. But I stuck an arbitrary hard value in the test stack I made, and all was in lock-step.

Craig

Re: scrolling background with gaps

Posted: Tue Dec 10, 2013 6:58 pm
by star0629
Im so lost and confused what to do..also the fact it must have gaps in between the images and that is the main problem..it wont display they gaps and overlaps each other instead :/

Re: scrolling background with gaps

Posted: Tue Dec 10, 2013 10:33 pm
by Simon
it wont display they gaps and overlaps each other instead :/
That is why I suggested using the right and left of the images... can't overlap.

Simon

Re: scrolling background with gaps

Posted: Wed Dec 11, 2013 12:59 am
by dunbarx
Simon.
once "image1" goes off the card (left side) it reappears from the right side of the card (here is when is begins to overlap) whilst "image1" is scrolling along as expected, "image2" has gone of the card (left side) and where there is supose to be a gap between the two images is filled up and the "image2" appears closer to "image1" as if "image2" is moving at a faster rate than "image1" this continues until "image2" has gone in front of "image1" somehow.
But he is saying that the one image continually advances over another at each pass. You have fixed the overlap, but there is something else going on that I do not see. I have lock-step. He has changing relative horizontal motion.

Craig

Re: scrolling background with gaps

Posted: Wed Dec 11, 2013 1:48 am
by Simon
Hi Craig,
Yes, sorry, the move rates are different, now I get it.
I messed up on what the "set the left of the image "bg1" to the left of the image "bg1" - 4" was for.

And for my sins I attach a stack that proves essentially star0629 code works (with fixes mentioned by Klaus and Craig).
So there is something else in the code setting positions of the images.

Unless I got it all wrong again :oops:

Simon

Re: scrolling background with gaps

Posted: Wed Dec 11, 2013 4:35 am
by dunbarx
Simon.

I think the mystery lies with Mr. Star.

Mr Star?

Craig

Re: scrolling background with gaps

Posted: Fri Dec 13, 2013 9:40 pm
by star0629
Thanks everyone for your help somehow got it to work..not exactly as i hoped, but it works.