背景: #EDF0F5 #FAFBE6 #FFF2E2 #FDE6E0 #F3FFE1 #DAFAF3 #EAEAEF 默认  
阅读新闻

人物走动的类

[日期:2004-10-03] 来源:  作者: [字体: ]
才写出来的,好些方法还没有实现呢,大家PP,
点击浏览该文件

import mx.data.emath.CMath;
class Fairy extends MovieClip {
public var m_position:Object;
public var m_StartPosition:Object;
public var m_EndPosition:Object;
public var m_Moveing:Boolean = false;
public var m_walkVel:Number;
private var m_nXVel:Number, m_nYVel:Number;
private var m_nIntervalID:Number;
private var m_nfps:Number = 50;
private var m_walkDir:String;
private var Man:MovieClip;
private var FF:MovieClip,BB:MovieClip,LL:MovieClip,RR:MovieClip,LB:MovieClip,RB:MovieClip,LF:MovieClip,RF:MovieClip
private var m_nwalkDistence:Number;
private var m_randomACT;
function Fairy() {
trace(Man.FF); m_walkVel = 2;
onMuseDown();
Position={x:0,y:0}
}
function set Position(p:Object) {
m_position = p;
_x = p.x;
_y = p.y;
}
function onMuseDown() {
var someListener = new Object();
var taget = this;
someListener.onMouseDown = function() {
trace("ddddddddddd");
taget.MoveTo(_root._xmouse, _root._ymouse);
};
Mouse.addListener(someListener);
}
function MoveTo(eX, eY) {
m_StartPosition = {x:_x, y:_y};
m_EndPosition = {x:eX, y:eY};
m_nwalkDistence = CMath.distance(_x, _y, eX, eY);
var nAngle = CMath.fixAngle(CMath.atan2D(eY-_y, eX-_x));
FaceTo(nAngle);
m_nYVel = CMath.sinD(nAngle)*m_walkVel;
m_nXVel = CMath.cosD(nAngle)*m_walkVel;
trace(m_nwalkDistence);
trace(nAngle+"____________");
if (!m_Moveing)
{
m_Moveing = true;
StartMove();
}
}
function FaceTo(Angle:Number) {
trace(this.RR); if (Angle>=0 && Angle<22.5)
{
//Right
trace("right");
m_walkDir="RR"
this.gotoAndPlay("RR1")

}
else if (Angle>=22.5 && Angle<67.5)
{
trace("right front");
m_walkDir="RF"

this.gotoAndPlay("RF1");
}
else if (Angle>=67.5 && Angle<112.5)
{
trace("front");
m_walkDir="FF"

this.gotoAndPlay("FF1");
}
else if (Angle>=112.5 && Angle<157.5)
{
trace("left front");
m_walkDir="LF"

this.gotoAndPlay("LF1");
}
else if (Angle>=157.5 && Angle<202.5)
{
trace("left");
m_walkDir="LL"

this.gotoAndPlay("LL1");
}
else if (Angle>=202.5 && Angle<247.5)
{
trace("left back");
m_walkDir="LB"

this.gotoAndPlay("LB1");
}
else if (Angle>=247.5 && Angle<292.5)
{
trace("back");
m_walkDir="BB"

this.gotoAndPlay("BB1");
}
else if (Angle>=292.5 && Angle<337.5)
{
trace(" right back");
m_walkDir="RB"

this.gotoAndPlay("RB1");
}
else if (Angle>=337.5 && Angle<360)
{
trace("right");
m_walkDir="RR"

this.gotoAndPlay("RR1");
}
}
function StartMove() {
this.m_nIntervalID = setInterval(this, "onMoveing", 1000/m_nfps);
}
function StopMove() {
clearInterval(this.m_nIntervalID);
this.gotoAndStop(m_walkDir)
this.gotoAndStop(m_walkDir)
m_Moveing = false;

}
function NextPosition() {
_x += m_nXVel;
_y += m_nYVel;
//this.nextFrame()

HitTest();
var nD = CMath.distance(_x, _y, m_StartPosition.x, m_StartPosition.y);
//trace(nD+"___"+m_nwalkDistence)
if (nD>=m_nwalkDistence)
{
Position(m_EndPosition);
StopMove();
}
}
function onMoveing() {
NextPosition();
}
function HitTest() {
var dd;
}
function swapDepth() {
var sss;
}
function actbroadcast() {
var bb;
}
}
阅读:
录入:admin

推荐 】 【 打印
上一篇:简单的检测鼠标是否有移动的类
下一篇:怎样制作loading
相关新闻      
本文评论       全部评论
发表评论


点评: 字数
姓名:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款