PDA

View Full Version : Screen jump


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

pradvan
12-15-2008, 04:23 PM
I looked at your game and I didn't see the screen jumping. Maybe you could provide an exact example of your problem? Or at least the needed steps to replicate the problem?

EightySeven
12-16-2008, 04:09 PM
I've uploaded a more up-to-date version of the game where there is a much more drastic version of what u were seeing earlier..the code for that section hasn't changed so it is as it was in the version uploaded above.

http://hardcircle.com/Games/Elemental/Elemental.html

for the more drastic result jump into the water and press 3 (u change to blue sprite) swim to the bottom then swim out of the water and press 2. You'll be a teal sprite press up or w to fly up and u will see the screen JUMP to the top which is not what I intended. if you release the teal form by pressing 1 or 3 you will fall to the ground and the screen will smoothly scroll with u as u fall. this is what I'd like to happen when u fly up. a nice smooth transition

pradvan
12-16-2008, 04:39 PM
Ok i see the screen jumping problem.

But, again, in the sample fla you provided, there is no way to test for this. How would someone know if they fixed your problem without being able to test?

I understand that you don't want to give away all your code and graphics. But if you want help you really need to start sharing. If someone needs to "steal" your game, they wont get far with it. If someone knows what they're doing, it would be easier for them to create their own.

fitz
12-16-2008, 04:47 PM
I had to add moveUp to his original FLA to make it testable, but it turns out it's just a logic thing. gamelevel.y is always less than 0, so when you were testing for gamelevel.y < 0 then set it to 0, that was causing the jump. It's actually needs to that if it becomes > 0. Also, the gamelevel.y += stagePositiony - topEdge, since it's always minus, needs to be gamelevel.y -= not +=. It only took a few traces to figure.

These changes make it work great:


if (stagePositiony < topEdge) {
gamelevel.y -= stagePositiony - topEdge;
if (gamelevel.y > 0) {
gamelevel.y = 0;
}
}

pradvan
12-16-2008, 04:59 PM
I had to add moveUp to his original FLA to make it testable

That was very nice of you fitz. But I don't think that the people trying to help should do extra work. It's just a principle thing.

fitz
12-16-2008, 05:39 PM
That was very nice of you fitz. But I don't think that the people trying to help should do extra work. It's just a principle thing.

Oh I agree completely. I first looked at this last week, and upon not being able to figure out how to even move up, I just closed it and moved on. When he reposted with the update, and I could see the problem in his SWF, I was intrigued enough to implement moveup in his original fla.

EightySeven
12-16-2008, 06:47 PM
Wow, ok now I feel like a fool.

And I'm more then willing to share my code all anyone has to do is just ask. though they should be prepared I'm told my organization is hectic.

new version has up and down movement functions. I'll remember that stuff next time I need help.

Thanks a bunch

fitz
12-16-2008, 07:30 PM
No problem, you are welcome! :) p.s. keep me posted on the game's progress, it looks interesting.

EightySeven
12-17-2008, 01:04 AM
well today I added destructable boxes, made the fire elemental glow in the dark and when u walk by candles in the fire element they light the candles which illuminates the room. and various other tweaks to swimming and flying


the graphics are obviously placeholders the guys that do the art are currently working on another game which I've already finished the code for.

And I'm not very artistic as u can tell lol