Solid object? [AS2]
- stickman8190
-
stickman8190
- Member since: Mar. 7, 2012
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
I would like to know how to make a solid object so my player can't go through the solid block.
This is the code I used for the player_mc
onClipEvent(load){
speed=5;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT) || Key.isDown(68)){
_x+=speed;
}
if(Key.isDown(Key.LEFT)|| Key.isDown(65)){
_x-=speed;
}
}
onClipEvent(enterFrame){
if(Key.isDown(Key.UP) || Key.isDown(87)){
_y-=speed;
}
if(Key.isDown(Key.DOWN) || Key.isDown(83) ){
_y+=speed;
}
}
the instance name for the moving player is "player_mc"
and the stances name for the wall is "wall_mc"
So any idea?
- caseymacneil
-
caseymacneil
- Member since: Nov. 19, 2008
- Offline.
-
- Forum Stats
- Member
- Level 06
- Programmer
okay so what your looking for is "collision response" not solid objects, that makes people think you want a filled in object or something. anyways if you think logically you could easily figure out a simple way of handling collision response; your object it moving towards a wall, when its touching the wall set it to the last position it was at before it hit the wall, boom! you cant walk through that wall now.
- stickman8190
-
stickman8190
- Member since: Mar. 7, 2012
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
At 5/25/12 02:03 PM, caseymacneil wrote: okay so what your looking for is "collision response"
thanks for that! when you said collision response and I search it and I found one!


