ive been playing with this script i got from another post about automatic scrolling, and i have been tryng to edit it or understand parts of it to make it work like this... once the player has walked to the right and the screen moves forward that you cant walk back wards, the screen only scrolls to the right but not to the left, AND the player cantwalk off screen(to the left) so it acts like a solid wall,(like the first mario bros i think) so far ive just got errors... any help will be much appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So basically you want to get rid of the automatic part. Right?
Okay, so here's what you do. Take the original script.
Basically, what you're going to do is gut the OnAfterMoveSprite sub. Between the
With ProjectObj.GamePlayer
and
End With
Lines, take almost all of it out. Leave only this line:
.rMap.Draw XOff, .MapScrollY
Now, before that line and after the With line put this:
if .PlayerSprite.X > XOff + .rMap.ViewWidth - .PlayerSprite.width - 16 then XOff = XOff + 1
Which will check to see if the player sprite is 16 pixels or less away from the right edge, and if it is, then it will scroll to the right. You can change the 16 to be a larger number if you want.
Note that this is not tested, just it should work.
And make sure the line you add (the if statement) is all on one line.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ive been playing with this script i got from another post about automatic scrolling, and i have been tryng to edit it or understand parts of it to make it work like this... once the player has walked to the right and the screen moves forward that you cant walk back wards, the screen only scrolls to the right but not to the left, AND the player cantwalk off screen(to the left) so it acts like a solid wall,(like the first mario bros i think) so far ive just got errors... any help will be much appreciated.
So basically you want to get rid of the automatic part. Right?
Okay, so here's what you do. Take the original script.
Basically, what you're going to do is gut the OnAfterMoveSprite sub. Between the
With ProjectObj.GamePlayer
and
End With
Lines, take almost all of it out. Leave only this line:
.rMap.Draw XOff, .MapScrollY
Now, before that line and after the With line put this:
if .PlayerSprite.X > XOff + .rMap.ViewWidth - .PlayerSprite.width - 16 then XOff = XOff + 1
Which will check to see if the player sprite is 16 pixels or less away from the right edge, and if it is, then it will scroll to the right. You can change the 16 to be a larger number if you want.
Note that this is not tested, just it should work.
And make sure the line you add (the if statement) is all on one line.
Oh, I forgot. You'll need to add a few more lines after the one you just added.
If .PlayerSprite.X < .XOff then .PlayerSprite.X = .XOff
If .XOff + .rMap.ViewWidth > .rMap.MapWidth then .XOff = .MapWidth - .rMap.ViewWidth