there is a way to make this stop at the edge of the sprite world? so you dont have the black screen whem go to the final of the world height?
This is the code right now:
_y += (player.y - _y) / smothness;
root.scrollRect = new Rectangle(_x - stage.stageWidth/2, _y - stage.stageHeight/2, stage.stageWidth, stage.stageHeight);
try something like
var WORLD_HEIGHT : Int = 600;
_y += (player.y - _y) / smothness;
_y = Math.min(WORLD_HEIGHT, _y);
i try that, but no changes
Make sure you include the size of your screen in your calculation.
If you have an origin point at (0, 0), then your smallest y
would be -WORLD_HEIGHT + screen.height
will try that today, but dont understand very well
If I have a screen that is 400 pixels tall, but a world that is 1000 pixels in height, setting the y
value to -1000
would cause the entire world to be off-screen. The smallest y
value would be -1000 + 400
, or -600
, so all of the world (except for the full height of the screen) is above the screen