# Collision and Animation?

**URL:** https://forum.kirupa.com/t/collision-and-animation/310583
**Category:** flash
**Created:** [June 14, 2010, 12:06pm UTC](https://forum.kirupa.com/t/collision-and-animation/310583 "2010-06-14T12:06:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![12sea21](https://avatars.discourse-cdn.com/v4/letter/1/ed8c4c/32.png) [@12sea21](https://forum.kirupa.com/u/12sea21)
#### Post date: [June 14, 2010, 12:06pm UTC](https://forum.kirupa.com/t/collision-and-animation/310583/1 "2010-06-14T12:06:55Z")

</div>

Important:  
[LIST]  
[_]ActionScript 2.0  
[_]Flash CS3  
[\*]I have some knowledge in Java and C++ which makes this easier… 🙂  
[/LIST]Im trying to make a game and the collision \*\*\* does not stop the character in its spot… if i set \_y to 0 then it would go to the top of the screen… if i set \_y to -1 each frame that the hitTest is active then the character goes through the platform and the rises by -1 (1 up) \_y … how can i make it so the character is stopped immediatly when touching (hitTest) the platform?

```auto
//this is what i wrote
onClipEvent(enterFrame){
 if(wall.hitTest(hero)){
  _root.hero._y -= 2;
 }
}
//This is what i got from a website (end)
onClipEvent (enterFrame) { 
 if (this.hitTest(_root.man)) { 
  _root.map._y -=5; 
 }
}
//this works as the problem
onClipEvent(enterFrame){
 if(wall.hitTest(hero)){
  _root.hero._y -= 2;
 }
}
//To reproduce the problem, swap "wall" with "this",
//put _root. before "hero".
//thats it... and that reproduced the problem.
//website:http://max-flashtutorials.blogspot.com/search/label/hit%20test
//so:
onClipEvent(enterFrame){
 if(this.hitTest(_root.hero)){
  _root.hero._y -= 2;
 }
}
//and that shall reproduce the poblem

```

And for my second problem:

1. how can i make my character move when the RIGHt/LEFT/UP/DOWN or WASD keys are pressed (animation move… not x,y).  
i made the animations but the animations do not stop when i dont press anything…
2. the same character ^^^^^ i put walls around the playing area… and i want the character to STOP DEAD when touching them… meaning STOP completely… unmovable in the wall’s direction.  
:(:crying::cry3:

[http://www.swfcabin.com/open/1276513279](http://www.swfcabin.com/open/1276513279) is the “game” if you can call it that.  
Help appreciated!!
