00:00
-:-
--:-- / --:--
Newgrounds Background Image Theme

RavenDrawz just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Actionscript help needed

875 Views | 11 Replies
New Topic Respond to this Topic

http://www.newgrounds.com/dump/item/9e49 0039781dbd5c4eaf88a0043b5ae5 is what i have soo far but how can i fix the sliding when you stop and when you run left and stop it stays facing left instaid of turning right

Response to Actionscript help needed Jan 26, 2010


Response to Actionscript help needed Jan 26, 2010


Post your Code/Actionscript 2 or 3?
Give us something to work with


No matter what your weaknesses are, make sure your own abilities supersede them.

Response to Actionscript help needed Jan 26, 2010


At 1/26/10 09:37 PM, CompleteDouche wrote: Post your Code/Actionscript 2 or 3?
Give us something to work with

as2

and

onClipEvent (load)
{
acceleration = 5.000000E-001;
xspeed = 0;
yspeed = 0;
friction = 2.500000E-001;
gravity = 4.000000E-001;
jumppower = 10;
}
onClipEvent (enterFrame)
{
if (xspeed > 0)
{
jumppower = 10 + xspeed / 10;
} // end if
if (xspeed < 0)
{
jumppower = 10 - xspeed / 10;
} // end if
if (Key.isDown(37))
{
xspeed = xspeed - acceleration / 5;
} // end if
if (Key.isDown(39))
{
xspeed = xspeed + acceleration / 5;
} // end if
if (yspeed < -5.000000E-001 && xspeed > 0)
{
_root.hit = 0;
gotoAndStop(3);
}
else if (yspeed > 5.000000E-001 && xspeed > 0)
{
_root.hit = 0;
gotoAndStop(4);
}
else if (yspeed < -5.000000E-001 && xspeed < 0)
{
_root.hit = 0;
gotoAndStop(6);
}
else if (yspeed > 5.000000E-001 && xspeed < 0)
{
_root.hit = 0;
gotoAndStop(7);
}
else if (yspeed < -5.000000E-001)
{
_root.hit = 0;
gotoAndStop(3);
}
else if (yspeed > 5.000000E-001)
{
_root.hit = 0;
gotoAndStop(4);
}
else if (xspeed < -1)
{
gotoAndStop(5);
}
else if (xspeed > 1)
{
gotoAndStop(2);
}
else if (xspeed > -1 && xspeed < 1 && yspeed > -1 && yspeed < 1)
{
gotoAndStop(1);
} // end else if
setProperty("", _y, _y + yspeed);
setProperty("", _x, _x + xspeed);
yspeed = yspeed + gravity;
if (_root.hit == 1)
{
if (xspeed < 0)
{
xspeed = xspeed + friction;
} // end if
if (xspeed > 0)
{
xspeed = xspeed - friction;
} // end if
if (Key.isDown(32))
{
yspeed = yspeed - jumppower;
_root.hit = 0;
}
else if (Key.isDown(38))
{
yspeed = yspeed - jumppower;
_root.hit = 0;
} // end else if
if (Key.isDown(37))
{
xspeed = xspeed - acceleration;
} // end if
if (Key.isDown(39))
{
xspeed = xspeed + acceleration;
} // end if
} // end if
}

Response to Actionscript help needed Jan 26, 2010


if you wanna download the source to scan for more errorsSouce

Response to Actionscript help needed Jan 27, 2010


This screams "decompiled". Try actually writing your own code, you will find that you will have a better chance of understanding it then.


Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.

Response to Actionscript help needed Jan 27, 2010


At 1/27/10 04:45 AM, henke37 wrote: This screams "decompiled". Try actually writing your own code, you will find that you will have a better chance of understanding it then.

it wasnt it was from a tut

Response to Actionscript help needed Jan 27, 2010


At 1/27/10 10:30 AM, wobbier wrote: it wasnt it was from a copy-and-paste

corrected

You see, thats your problem. Copy and pasting is gonna get you no where. Learn code


AS2||AS3||Motox

Thanks to hdxmike for the sig :]

BBS Signature

Response to Actionscript help needed Jan 27, 2010


At 1/27/10 11:03 AM, Yambanshee wrote:
At 1/27/10 10:30 AM, wobbier wrote: it wasnt it was from a copy-and-paste
corrected

You see, thats your problem. Copy and pasting is gonna get you no where. Learn code

thats the problem i cant find a legit code tut i always find crap. link for good tuts?

Response to Actionscript help needed Jan 27, 2010


At 1/27/10 02:33 PM, HDXmike wrote:
At 1/27/10 02:06 PM, wobbier wrote:
At 1/27/10 11:03 AM, Yambanshee wrote:
At 1/27/10 10:30 AM, wobbier wrote: it wasnt it was from a copy-and-paste
corrected

You see, thats your problem. Copy and pasting is gonna get you no where. Learn code
thats the problem i cant find a legit code tut i always find crap. link for good tuts?
Jesus , you dont fucking LEARN FROM FUCKING TUTS , you cant just get knowledge implanted in your brain for fucks sake , he said LEARN , tutorials should only be used for small code problems/solutions , the only way you could end up with that code is from typing into google "How to make a flash game " or something similarly vague. Ive taken 2 tutorials in my entire life , 1 for the scribble cel and one for complex buttons when i first started flash , then i learned everything myself and with the OCCASIONAL help from the NG forums , adobe has written mountains of help for you and a huige index to explore make use of it
</semiflame>
I blame yambanshee for being so right

calm down you cant learn if you dont take a tutorial adobe wrote a tutorial cause it shows you how to do it so dont say you just learned flash somehow you've definately read tuts or you wouldnt be as good as you were now.

Response to Actionscript help needed Jan 27, 2010


ive never read ur code at all but my style of making platformers is kind of like that.. and i call that "glitch" the friction not a factor of acceleration.. imagine ur current velocity is now 5 and ur friction is 2... i

frame 1: xvel=5;
frame 2: xvel=3;
frame 3: xvel=1;
frame 4: xvel=-1; //this is where the glitch starts
frame 5: xvel=1; // and it keeps looping here on out

if(xvel<0){
xvel+=frc;
}else if(xvel>0){
xvel-=frc;
}

due to the friction not being a factor of the xvel. u tend to move when ur xvel is close to 0. which direction depends.. if u put xvel>0 check last it will be moving left xvel<0 check last it will be moving right.

to fix the glitch add in a"speed balancer" as i call it... it detects that the velocity is within that range and then assign it to 0

if(xvel>-friction&&xvel<friction){ xvel=0; }

this way once the xvel falls below friction value.. which means it will glitch.. the code will assign xvel to 0 hence stops moving. =D
in this way, once ur


BBS Signature

Response to Actionscript help needed Jan 28, 2010


thanks