Be a Supporter!

bit of a problem

  • 431 Views
  • 3 Replies
New Topic Respond to this Topic
Disarray-yarrasiD
Disarray-yarrasiD
  • Member since: Nov. 14, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
bit of a problem 2005-08-13 14:28:30 Reply

my character seems to be having troble detecting where the walls are, it is a though they exist in some places but not in others.

this is the complete code for the character(the only code in the game at this point):

the wall's instance is wall

onClipEvent (load) {
defending = false;
gonext = false;
magic = false;
firespeer = false;
fireball = true;
stop1 = false;
stop2 = false;
attacking1 = false;
attacking2 = false;
wallhit = false;
delay = 5;
movement = 8;
xSpeed = 0;
ySpeed = 0;
i = 100;
}
onClipEvent (enterFrame) {
Xspacer = 5*xSpeed;
Yspacer = 5*ySpeed;
if (_root.wall.hitTest(this._y-Yspacer, this._x+Xspacer, true)) {
wallhit = true;
} else {
wallhit = false;
}
if (moving && !attacking1 && !attacking2 && !defending && !magic) {
gotoAndStop(2);
} else {
if (!moving && !attacking1 && !attacking2 && !defending && !magic) {
gotoAndStop(1);
}
}
if (Key.isDown(Key.UP) && !defending && !magic && !wallhit) {
moving = true;
} else {
moving = false;
}
if (Key.isDown(Key.LEFT) && !attacking1 && !attacking2 && !magic) {
_rotation -= 30;
}
if (Key.isDown(Key.RIGHT) && !attacking1 && !attacking2 && !magic) {
_rotation += 30;
}
if (Key.isDown(65) && gonext && !defending or attacking2 && !defending && !magic) {
gotoAndStop(4);
} else {
if (Key.isDown(65) && !gonext && !defending or attacking1 && !defending && !magic) {
gotoAndStop(3);
}
}
if (Key.isDown(83) && !attacking1 && !attacking2 && !magic && !magic) {
defending = true;
gotoAndStop(5);
} else {
defending = false;
}
if (Key.isDown(68) && !attacking1 && !attacking2 && !defending or magic && !attacking1 && !attacking2 && !defending) {
gotoAndStop(6);
}
if (magic && firespeer && cando) {
i++;
_root.attachMovie("firespeer", "firespeer"+i, i);
_root["firespeer"+i]._rotation = _rotation;
_root["firespeer"+i]._y = _y-xSpeed;
_root["firespeer"+i]._x = _x+ySpeed;
_root["firespeer"+i].delay = 10;
_root["firespeer"+i]._xscale = 50;
_root["firespeer"+i]._yscale = 50;
_root["firespeer"+i].onEnterFrame = function() {
this.xSpeed = 30*Math.sin(this._rotation*(Math.PI/180));
this.ySpeed = 30*Math.cos(this._rotation*(Math.PI/180));
this._x += this.xSpeed;
this._y -= this.ySpeed;
this.delay--;
if (this.delay<0) {
this._alpha -= 30;
}
if (this.delay<-2) {
this.removeMovieClip;
}
};
}
if (magic && fireball && cando) {
i++;
_root.attachMovie("fireball", "fireball"+i, i);
_root["fireball"+i]._rotation = _rotation;
_root["fireball"+i]._y = _y-xSpeed;
_root["fireball"+i]._x = _x+ySpeed;
_root["fireball"+i].delay = 20;
_root["fireball"+i]._xscale = 50;
_root["fireball"+i]._yscale = 50;
_root["fireball"+i].onEnterFrame = function() {
this.delay--;
if (this.delay>7) {
this.gotoAndStop(1);
this.xSpeed = 25*Math.sin(this._rotation*(Math.PI/180));
this.ySpeed = 25*Math.cos(this._rotation*(Math.PI/180));
this._x += this.xSpeed;
this._y -= this.ySpeed;
}
if (this.delay<5 && this.delay>0) {
this.gotoAndStop(2);
this._x += 0;
this._y += 0;
}
if (this.delay<0) {
this._alpha -= 30;
}
if (this.delay<-2) {
this.removeMovieClip;
}
};
}
xSpeed = movement*Math.sin(_rotation*(Math.PI/180))
;
ySpeed = movement*Math.cos(_rotation*(Math.PI/180))
;
if (moving) {
this._y -= ySpeed;
this._x += xSpeed;
_root._x -= xSpeed;
_root._y += ySpeed;
}
}

this is an example of the problem:
http://img254.images..ge=bbsproblem0of.swf


BBS Signature
Darkaxl
Darkaxl
  • Member since: Oct. 23, 2004
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to bit of a problem 2005-08-13 14:31:56 Reply

Im kinda new but i thikn it might be that u have some underline layers that u havent realised ther?


BBS Signature
Disarray-yarrasiD
Disarray-yarrasiD
  • Member since: Nov. 14, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to bit of a problem 2005-08-13 14:55:03 Reply

so.. do you know how to fix this?


BBS Signature
Disarray-yarrasiD
Disarray-yarrasiD
  • Member since: Nov. 14, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to bit of a problem 2005-08-13 15:10:00 Reply

ok...wtf

i changed:

this._x+Xspacer,this._y+Yspacer,true

to:

_root._x+Xspacer,_root._y+Yspacer,true

and it works perfectly, can someone please tell me why?


BBS Signature