At 8/13/04 03:50 PM, PunkerFish wrote:
Mmm...quick question.
How would I go about scrolling with no instance names?
Wow! I can't believe this topic is still alive. I went to Saint Croix for a week (which is why no one could reach me), and thought it would die off.
Anyway, to answer you question, yes, I do have code for an instance-nameless sidescroller. This, obviously, works in tune with the jumping engine (you need to put it in with the engine to make it work). It's slightly complex, but here goes:
First, make a LONG, VERTICAL box on the right. Put it off screen (there is a variation to this, which I will explain later). Then, add this code:
-------------------------------------------------------------
onClipEvent (enterFrame) {
x++;
if (hitTest(_root.circle)) {
_global.moveX = 1;
x=0;
}
if (x==5 && _global.moveX==1) {
_global.moveX=0;
}
}
-------------------------------------------------------------
Do the same thing on the left, except add this code:
-------------------------------------------------------------
onClipEvent (enterFrame) {
x++;
if (hitTest(_root.circle)) {
_global.moveX = -1;
x=0;
}
if (x==5 && _global.moveX==-1) {
_global.moveX=0;
}
}
-------------------------------------------------------------
Then, put this in EVERY CLIP . I CANNOT EMPHASIS HOW IMPORTANT PUTTING IT IN EVERY CLIP IS (other then the vertical boxes. Don't put it in them. Also, don't put it in things that you don't want to scroll, such as the wall blocking off the end of the level).
onClipEvent (enterFrame) {
if (_global.moveX>0) {
_x -= _root.circle.speed;
}
if (_global.moveX<0) {
_x += _root.circle.speed;
}
}
And there ya go! It sidescrolls. This code hasn't been extensively tested like the jumping engine has, so an error or two may occur. If that does happen, e-mail me at Rystic_Force@hotmail.com, or IM me (IMing preferred; we usually get more work done that way).
VARIATION
An alternitive, which I do recommend, is putting the vertical boxes in the center, on the sides of but not touching the player. This gives the feel of an old side scroller, such as Mario, but requires the player to stand in the center (which is why I didn't post it originally. Flexability). Frankly, if I were to make a game (maybe one day), I would use this version.
-Rystic