Показать сообщение отдельно
Старый 17.10.2009, 06:31
dirrect вне форума Посмотреть профиль Отправить личное сообщение для dirrect Найти все сообщения от dirrect
  № 9  
Ответить с цитированием
dirrect

Регистрация: Oct 2009
Адрес: Комсомольск-на-Амуре
Сообщений: 4
Вот держи финальную версию:
Код AS1/AS2:
var goHome:Boolean = true;
_root.Rastenie.cel._visible = false;
// координаты кнопки
var homeX:Number = Rastenie._x;
var homeY:Number = Rastenie._y;
var mX:Number = homeX;
var mY:Number = homeY;
var sA:Number = -20;//угол отклонения
// скорость движения
var spd:Number = 4;
// скорость поворота
var spdR:Number = 2;
// процедура
getCelXY = function(){
	var myPoint = {x:0, y:0};
	_root.Rastenie.cel.localToGlobal(myPoint);
	mX=myPoint.x;
	mY=myPoint.y;
	//trace("myPoint_x - "+myPoint.x);
}
_root.onEnterFrame = function() {
	if (goHome){
		getCelXY();
	}
	delta_x = Math.floor(ladybird._x-mX);
	delta_y = Math.floor(ladybird._y-mY);
	targetRotation = -Math.atan2(delta_x, delta_y)/(Math.PI/180)+sA;
	rast = Math.sqrt((delta_x*delta_x)+(delta_y*delta_y));
	if (rast>=spd+20) {
		ladybird.gotoAndStop(2);
	} else {
		ladybird._rotation=targetRotation;
		ladybird.gotoAndStop(1);
 
	}
	if (rast>=spd+10) {//20 - это радиус круга попадая в который коровка перестает лететь
		if (Math.abs(Math.abs(Math.floor(ladybird._rotation))-Math.abs(targetRotation))<5) {
			ladybird._rotation=targetRotation;
		} else {
			ladybird._rotation += spdR;
		}
		ladybird._x += spd*Math.sin((ladybird._rotation)*(Math.PI/180));
		ladybird._y -= spd*Math.cos((ladybird._rotation)*(Math.PI/180));
	}
};
mouseOnButton = function(){
	goHome = false;
	mX = Math.floor(_xmouse);
	mY = Math.floor(_ymouse);
}
mouseOutButton = function(){
	goHome = true;
}
//кнопки
btn_1.onPress = function() {
};
btn_1.onRollOver = function(){
	mouseOnButton();
}
btn_1.onRollOut = function(){
	mouseOutButton();
}
//
btn_2.onPress = function() {
};
btn_2.onRollOver = function(){
	mouseOnButton();
}
btn_2.onRollOut = function(){
	mouseOutButton();
}
//
btn_3.onPress = function() {
};
btn_3.onRollOver = function(){
	mouseOnButton();
}
btn_3.onRollOut = function(){
	mouseOutButton();
}
в исходнике все понятно.
Вложения
Тип файла: rar fly_of_ladybird.rar (21.3 Кб, 68 просмотров)