onClipEvent(load){
moveSpeed=5;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.UP)){
this._y-=moveSpeed;
}
if(Key.isDown(Key.DOWN)){
this._y+=moveSpeed;
}
if(Key.isDown(Key.LEFT)){
this._x-=moveSpeed;
}
if(Key.isDown(Key.RIGHT)){
this._x+=moveSpeed;
}
}
onClipEvent(enterFrame){
if(this.hitTest(_root.Wall)){
this._x+=moveSpeed;
}
if(this.hitTest(_root.Wall)){
this._x-=moveSpeed;
}
if(this.hitTest(_root.Wall)){
this._y+=moveSpeed;
}
if(this.hitTest(_root.Wall)){
this._y-=moveSpeed;
}
} Im not sure why it doesnt work when i try to hit the object Wall I just pass through it...help guys.[Flash]ActionScript2.0 Help thread
Started by: DarkCloud | Replies: 8 | Views: 550
Dec 26, 2009 3:14 AM #528686
Ok guys if you haven't noticed I'ved asked for help on as2 many times and I need it again so if I have more questions(I probably will)I'll post them here unless a mod says I can't so anyways. I've made a hitTest but it doesnt work heres the code of the ball.
Dec 26, 2009 5:20 AM #528708
onClipEvent(load){
moveSpeed=5;
}
onClipEvent(enterFrame){if(Key.isDown(Key.UP) && this._y > top){
this._y-=moveSpeed;
}
if(Key.isDown(Key.DOWN && this._y < floor)){
this._y+=moveSpeed;
}
if(Key.isDown(Key.LEFT) && this._x < leftWall){
this._x-=moveSpeed;
}
if(Key.isDown(Key.RIGHT) && this._x > rightWall){
this._x+=moveSpeed;
}
}
roof = 0;
floor = document height
leftwall = 0;
rightwall = document width
That's all you need relle for collissions with the walls. HitTesting an object in the middle of the screen with a controlled player is much more advanced and requires more thought.
Dec 26, 2009 1:01 PM #528798
oh so you need like a right left top bottom wall crap.
Dec 26, 2009 1:41 PM #528808
I don't think you can use the onEnterFrame function on an object more than once.
Dec 26, 2009 1:58 PM #528810
oh I cant I didnt know that :Ohhhhh: .
Dec 26, 2009 8:41 PM #528859
this site
makes me so very proud to be a member ^_^
WUOSA> ! ! ! ! ! ! !
makes me so very proud to be a member ^_^
WUOSA> ! ! ! ! ! ! !
Dec 26, 2009 9:22 PM #528870
wtf who the hell are you...
Dec 27, 2009 5:07 AM #528956
Some kind of a begginer I think.
Dec 27, 2009 5:49 AM #528961
Quote from slipe_rock
WUOSA> ! ! ! ! ! ! !
It's obviously Martin Lawrence...