EightySeven
12-10-2008, 06:39 PM
Hey ya'll I've got a problem with my scrolling screen. when you fall everything is fine you fall and the screen falls with you nice and smooth. but when u fly up
it doesn't scroll up with you it jumps to the upper most corner
public function scrollWithHero() {
var stagePosition:Number=gamelevel.x + hero.mc.x;
var stagePositiony:Number = gamelevel.y + hero.mc.y;
var rightEdge:Number=stage.stageWidth - edgeDistance;
var leftEdge:Number=edgeDistance;
var topEdge:Number=edgeDistance;
var bottomEdge:Number=stage.stageHeight - edgeDistance;
if (stagePosition > rightEdge) {
gamelevel.x-= stagePosition - rightEdge;
if (gamelevel.x < - gamelevel.width - stage.stageWidth) {
gamelevel.x=- gamelevel.width - stage.stageWidth;
}
}
if (stagePosition < leftEdge) {
gamelevel.x+= leftEdge - stagePosition;
if (gamelevel.x > 0) {
gamelevel.x=0;
}
}
if (stagePositiony < topEdge) {
gamelevel.y += stagePositiony - topEdge;
if (gamelevel.y < 0) {
gamelevel.y = 0;
}
}
if (stagePositiony > bottomEdge) {
gamelevel.y -= stagePositiony - bottomEdge;
if (gamelevel.y > gamelevel.height - stage.stageHeight) {
gamelevel.y = gamelevel.height - stage.stageHeight;
}
}
}
What I would like to happen is for the screen to not jump to the top but scroll nicely to the top.
I've uploaded the fla if u need to look at the whole game so far
any and all help would be wonderful
it doesn't scroll up with you it jumps to the upper most corner
public function scrollWithHero() {
var stagePosition:Number=gamelevel.x + hero.mc.x;
var stagePositiony:Number = gamelevel.y + hero.mc.y;
var rightEdge:Number=stage.stageWidth - edgeDistance;
var leftEdge:Number=edgeDistance;
var topEdge:Number=edgeDistance;
var bottomEdge:Number=stage.stageHeight - edgeDistance;
if (stagePosition > rightEdge) {
gamelevel.x-= stagePosition - rightEdge;
if (gamelevel.x < - gamelevel.width - stage.stageWidth) {
gamelevel.x=- gamelevel.width - stage.stageWidth;
}
}
if (stagePosition < leftEdge) {
gamelevel.x+= leftEdge - stagePosition;
if (gamelevel.x > 0) {
gamelevel.x=0;
}
}
if (stagePositiony < topEdge) {
gamelevel.y += stagePositiony - topEdge;
if (gamelevel.y < 0) {
gamelevel.y = 0;
}
}
if (stagePositiony > bottomEdge) {
gamelevel.y -= stagePositiony - bottomEdge;
if (gamelevel.y > gamelevel.height - stage.stageHeight) {
gamelevel.y = gamelevel.height - stage.stageHeight;
}
}
}
What I would like to happen is for the screen to not jump to the top but scroll nicely to the top.
I've uploaded the fla if u need to look at the whole game so far
any and all help would be wonderful