Ive also been having trouble puttiing this into words!
here goes
i want to implement in director a kind of interface like a landscape or
something, i want it to be possible for the user to scroll the landscape
left and right, but when the user has navigated to the far left(or far
right) then the landscape is looped, and they would if they left the
landscape at the right, they would find themself on the left.
i know its a sketchy despciption but if anyone could shed some light i would
be greatful!
thanks in advance, i hope!:)
mark
Make your image twice as wide as the full landscape, and repeat the landscape across the image. So you should still have a
continuous landscape.
Every frame, move the landscape x pixels to the left/right. Continuously check the loc of the image, and when you run out of image,
move it backwards by the width of the initial landscape.
Uhhh....example:
You have a movie 100 pixels wide.
You have a landscape 500 pixels wide.
Make your landscape image 1000 pixels wide, and tile it.
Place the regpoint of the image on the left edge - this makes checking its borders easier.
Let's say we're scrolling right.
on exitframe me
sprite(me.spriteNum).locH = sprite(me.spriteNum).locH + 5
if (sprite(me.spriteNum).locH >= 0)
sprite(me.spriteNum).locH = sprite(me.spriteNum).locH - 500
end if
end
So once the left hand edge of the image passes the left hand edge of the stage, you jump the image left by 500 pixels. Since the
image is repeated, the user won't notice the jump, and you can carry on scrolling.
Let me know if you hit any problems...
Jon
hi jon,
sorry to interupt this post but i just a a query about the syntax.
where you state:
"sprite(me.spriteNum)....."
Does the "me." part define an individual sprite even if it's member may be
duplicated several times on the stage?
If so what is the difference between "me." and "currentSpriteNum", do they
both do the same job?
cheers
..b..
Hmm....I've never heard of currentspritenum
[goes off to check the help file]
Yep - sounds exactly the same. It's just syntactical preference whether you prefer Director's (misguided) attempt at making Lingo
sound like English (the currentSpriteNum), or whether you prefer a more standard object-orientated fashion (me.spriteNum). :)
me. will refer to whatever the behaviour is attached to. Take a single image member, and repeat it on stage 5 times. Create a
single behaviour like this:
on exitFrame me
sprite(me.spriteNum).locH = sprite(me.spriteNum) + 1
end
and attach it to each one of those sprites. Every frame, the exitframe handler will be called seperately for each of those sprites,
and they'll all move 1 pixel to the right.
Jon
thought it might be.
learn something new everyday hey! :)
tar
..b..