I have been trying to read some physical materials over the past few days. However, as3.0 is always wrong When simulating a jump. This is the code of a certain game below. I have changed it to a lot of code, it's the simplest jumping experiment. If you are interested, try it, but as3.0 is really not familiar with it? I feel familiar with 2.0,
Let's take a look at the formula of physical oblique throwing and throwing, and try to continue learning more every day.
Onclipevent (load)
{
Function move (x, y)
{
This. _ x + = math. Cos (_ rotation * Math. PI/180) * X;
This. _ y + = math. Sin (_ rotation * Math. PI/180) * X;
If (! _ Root. Map. hittest (_ x, _ y + Y, true ))
{
This. _ y + = y;
}
}
}
Onclipevent (enterframe)
{
If (key. isdown (key. Up )&&! Jump)
{
Jump = true;
Vy =-10;
}
If (jump)
{
Move (0,-5 );
Move (0, Vy ++ );
Trace (Vy );
If (Vy> 14)
{
Jump = false;
}
}
If (1)
{
Move (0, 5); // The speed of dropping
}
If (key. isdown (key. Right ))
{
Move (5, 0 );
}
If (key. isdown (key. Left ))
{
Move (-5, 0 );
}
}