Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Character outrunning background

(167 views • 12 replies)

This topic is 1 page long.

<< < > >>
None

ProfessorFlash

Reply To Post Reply & Quote

Posted at: 12/5/07 04:28 PM

ProfessorFlash DARK LEVEL 16

Sign-Up: 10/06/07

Posts: 484

The title pretty much sums it up. But I'll elaborate on the problem. (check below flash, move with the arrow keys, up is jump)

Check this flash first to see my problem.

Now, as you can see. You can easily outrun the background. I dont understand why. Here is a little piece of the action script I use to move the character and the background (this is in the character movieclip, the backgrounds instance name is "screen"):

vx*=friction;
this._x+=vx;
_root.screen._x-=vx;

As you can see, the background should move exacly like the character, but it doesnt (friction is a number, 0.87, which I use to make the movement smooth). I'm puzzled, can someone help me figure out what is wrong?


None

ProfessorFlash

Reply To Post Reply & Quote

Posted at: 12/5/07 06:01 PM

ProfessorFlash DARK LEVEL 16

Sign-Up: 10/06/07

Posts: 484

*bump*

Can somebody can help me out?


None

criticalhammer1

Reply To Post Reply & Quote

Posted at: 12/5/07 06:15 PM

criticalhammer1 EVIL LEVEL 10

Sign-Up: 10/15/07

Posts: 300

At 12/5/07 06:01 PM, ProfessorFlash wrote: *bump*

Can somebody can help me out?

stfu

STEAM RULES BOW DOWN TO VALVe!

BBS Signature

PyroflameProductions NEUTRAL LEVEL 09

Sign-Up: 08/04/07

Posts: 1,957

At 12/5/07 06:15 PM, criticalhammer1 wrote:
At 12/5/07 06:01 PM, ProfessorFlash wrote: *bump*

Can somebody can help me out?
stfu

You stfu, he was just asking for help.

Sorry, I'm not sure exactly what is wrong either...

Free .fla's are currently down.

BBS Signature

None

Cojones893

Reply To Post Reply & Quote

Posted at: 12/5/07 06:24 PM

Cojones893 EVIL LEVEL 21

Sign-Up: 03/09/03

Posts: 2,193

show more code. Although you have shown where the problem should be there is obviously more to it.


None

DanBomer

Reply To Post Reply & Quote

Posted at: 12/5/07 06:32 PM

DanBomer LIGHT LEVEL 06

Sign-Up: 04/01/06

Posts: 306

try making friction: 0.95

Silly faggot, dicks are for chicks!

BBS Signature

Questioning

pt9-9

Reply To Post Reply & Quote

Posted at: 12/5/07 07:28 PM

pt9-9 NEUTRAL LEVEL 10

Sign-Up: 10/05/05

Posts: 746

_root.screen._x+=vx/2;

Does it need to be going backwards or something?


None

Moonkey

Reply To Post Reply & Quote

Posted at: 12/5/07 08:11 PM

Moonkey DARK LEVEL 07

Sign-Up: 05/11/07

Posts: 799

Looks like you've changed the scale of screen.


None

senior-twinki

Reply To Post Reply & Quote

Posted at: 12/5/07 08:18 PM

senior-twinki LIGHT LEVEL 10

Sign-Up: 06/26/07

Posts: 1,606

At 12/5/07 06:15 PM, criticalhammer1 wrote:
At 12/5/07 06:01 PM, ProfessorFlash wrote: *bump*

Can somebody can help me out?
stfu

bazing


None

ProfessorFlash

Reply To Post Reply & Quote

Posted at: 12/6/07 07:31 AM

ProfessorFlash DARK LEVEL 16

Sign-Up: 10/06/07

Posts: 484

Ah I've solved the problem. It was a simple solution after all. As you can see I am moving both the character and the background. That's why the character always gets infront. Now that I disabled the moving of the character, so only the background moves, it works just as I want. So the character always stays on the same spot on the stage, but because the background moves, it looks like you are moving.

Thanks to everybody who tryied to help. But I do have a follow up question, please refer back to my original post for the flash. As you can see, the character sinks in the platforms (the grey blocks). I have it coded that when it hitTests with the platform it reverses the gravity, so it lifts the character above the platform. How can I prevent it from sinking in and then raising, and then bouncing stupidly on top of the platform?


None

dogonfire

Reply To Post Reply & Quote

Posted at: 12/6/07 07:40 AM

dogonfire LIGHT LEVEL 06

Sign-Up: 11/26/07

Posts: 76

I assume he "sinks" in because the hittest doesnt happen often enough for your gravity value. The easy solution is, when your character hits a platform, change his y to that of the platform he hit, adjusting for his height.


None

Nuggs

Reply To Post Reply & Quote

Posted at: 12/6/07 08:32 AM

Nuggs LIGHT LEVEL 18

Sign-Up: 12/17/05

Posts: 1,201

or you could use a while() loop

while(character.hitTest(ground)){
character._y++
gravity=0
}else{
gravity=10
}

Games|1|2|3| Movies|1|2|

BBS Signature

None

ProfessorFlash

Reply To Post Reply & Quote

Posted at: 12/6/07 08:32 AM

ProfessorFlash DARK LEVEL 16

Sign-Up: 10/06/07

Posts: 484

At 12/6/07 07:40 AM, dogonfire wrote: I assume he "sinks" in because the hittest doesnt happen often enough for your gravity value. The easy solution is, when your character hits a platform, change his y to that of the platform he hit, adjusting for his height.

That does solve it. Thanks for the help.


All times are Eastern Daylight Time (GMT -4) | Current Time: 03:36 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!