Actionscript 3 保持box2d的球速
我用这个代码来创建和投球。我想提高球的速度,它应该保持速度直到它毁灭。我该怎么做才能得到结果Actionscript 3 保持box2d的球速,actionscript-3,flash,actionscript,box2d,Actionscript 3,Flash,Actionscript,Box2d,我用这个代码来创建和投球。我想提高球的速度,它应该保持速度直到它毁灭。我该怎么做才能得到结果 var sphereShape:b2CircleShape=new b2CircleShape(15/worldScale); var sphereFixture:b2FixtureDef = new b2FixtureDef(); sphereFixture.density=1; sphereFixture
var sphereShape:b2CircleShape=new b2CircleShape(15/worldScale);
var sphereFixture:b2FixtureDef = new b2FixtureDef();
sphereFixture.density=1;
sphereFixture.friction=3;
sphereFixture.restitution=0.1;
sphereFixture.filter.groupIndex = -1;
sphereFixture.shape=sphereShape;
ball_mc=new ballMc();
ballCont_mc.addChild(ball_mc);
var sphereBodyDef:b2BodyDef = new b2BodyDef();
sphereBodyDef.type=b2Body.b2_dynamicBody;
ball_mc.name="throwBall";
ball_mc.hitCount=0;
ball_mc.basketHit=0;
sphereBodyDef.position.Set(arrow_mc.x/worldScale,arrow_mc.y/worldScale);
birdSphere=world.CreateBody(sphereBodyDef);
birdSphere.CreateFixture(sphereFixture);girl_mc.gotoAndStop(3);
birdSphere.SetUserData(ball_mc);
birdSphere.SetBullet(true);
var distanceX:Number=arrow_mc.x-mouseX;
var distanceY:Number=arrow_mc.y-mouseY;
var distance:Number=Math.sqrt(distanceX*distanceX+distanceY*distanceY);
var birdAngle:Number=Math.atan2(distanceY,distanceX);
birdSphere.SetLinearVelocity(new b2Vec2(distance*Math.cos(birdAngle)/4,distance*Math.sin(birdAngle)/4));
有人能帮我吗?给球一个速度变量,并使用类似以下的功能:
function run(Self)
{
Self._x+=Math.sin(Self._rotation*(Math.PI/180))*Self.Speed/10;
Self._y+=Math.cos(Self._rotation*(Math.PI/180))*Self.Speed/10*-1;
}//------------------------------------------------------------^run
叫跑(ball_mc);你想让它移动的每一帧
保持速度变量,就像保持速度一样
自我就是球。您首先需要根据它应该移动的方向设置它的旋转,但这是另一个主题,所以我将节省空间并将该部分保留
我希望这有帮助。给球一个速度变量,并使用类似于以下的功能:
function run(Self)
{
Self._x+=Math.sin(Self._rotation*(Math.PI/180))*Self.Speed/10;
Self._y+=Math.cos(Self._rotation*(Math.PI/180))*Self.Speed/10*-1;
}//------------------------------------------------------------^run
叫跑(ball_mc);你想让它移动的每一帧
保持速度变量,就像保持速度一样
自我就是球。您首先需要根据它应该移动的方向设置它的旋转,但这是另一个主题,所以我将节省空间并将该部分保留
我希望这有帮助