Показать сообщение отдельно
Старый 30.10.2008, 00:58
Wolsh вне форума Посмотреть профиль Отправить личное сообщение для Wolsh Найти все сообщения от Wolsh
  № 2  
Ответить с цитированием
Wolsh
Нуб нубам
 
Аватар для Wolsh

модератор форума
Регистрация: Jan 2006
Адрес: Бердск, НСО
Сообщений: 6,445
Как-то так? (Вам не кажется, что количество this в этом коде слегка зашкаливает?)
Код:
var dX:Number = 0, dY:Number = 0;
var speedMc:Number = 0;
var maxSpeedMc:Number = 10;
var accelerationMc:Number = 0.5;
this.joystick.onPress = function() {
	this._parent.onEnterFrame = moveMc;
	// зачем эти переменные, если после отпускания 
        // джойстик встает в (100,100) и нажать его в другой позиции невозможно?
	//var dx0_joy:Number = this._x;
	//var dy0_joy:Number = this._y;
	this.startDrag(false,75,75,125,125);
	this.onMouseMove = checkJoystick;
};
this.joystick.onRelease = this.joystick.onReleaseOutside=function () {
	this.stopDrag();
	delete this.onMouseMove;
	this._x = 100;
	this._y = 100;
	delete this._parent.onEnterFrame;
};
function checkJoystick(){
	dX = (this._x-100)*4;
	dY = (this._y-100)*4;
}
function checking() {
	this.mc._x = (this.mc._x>490) ? 490 : this.mc._x;
	this.mc._x = (this.mc._x<210) ? 210 : this.mc._x;
	this.mc._y = (this.mc._y>340) ? 340 : this.mc._y;
	this.mc._y = (this.mc._y<60) ? 60 : this.mc._y;
}
function moveMc() {
	speedMc += (speedMc<maxSpeedMc) ? accelerationMc : 0;
	speedX_mc = speedMc*dX/100;
	speedY_mc = speedMc*dY/100;
	this.mc._x += speedX_mc;
	this.mc._y += speedY_mc;
	checking();
}
this.onEnterFrame = moveMc;
__________________
Reality.getBounds(this);