Newbie Collision Problem

Hello Kirupa Community,

am pretty new to Kirupa and Flash.

I have a little problem, concerning a character hitting a wall. :slight_smile:

What i have: a char that can jump and move around by the arrow keys.

What i need: character shall stop movement if he hits a geometry. But being able to start movement again, besides through the geometry. I´d like to reach this with gskinners CheckForCollision class. Have a look here: http://www.gskinner.com/blog/archives/2005/10/source_code_sha.html But i didnt manage my code to get it work. So maybe you could leak me some information on how to get this done.

Heres my code so far:

onClipEvent (load)
	{

		ymove = 0;
		xmove = 0;
		power = 5;
		gravity = 0.95;
		friction = 0.85;
		jumpForce = 5;
		jumping = false;
		
	}


onClipEvent (enterFrame)
	{

		
import com.gskinner.sprites.CollisionDetection;
if (CollisionDetection.checkForCollision(this,level,255))
			{	
				xmove = 0 / friction;
				ymove = 0 - gravity;
				
			}
		
		
		if (jumping)
			{	
				power = 1;
				ymove -= jumpForce;
				jumping = false;
			}
				
		if (Key.isDown(Key.LEFT))
			{
				xmove -= power;
			}
			
		if (Key.isDown(Key.RIGHT))
			{
				xmove += power;
			}
			
		if (Key.isDown(Key.UP))
			{
				jumping = true;
			}
			
			
		
		xmove *= friction;
		ymove += gravity;
		_y += ymove;
		_x += xmove;

	}

edit admits: so far i have a character mc called “player” and one called “level”.
i would apply the code to the player, and it would be cool to have the possibility to check collision of the player with multiple MCs, not only the level.

I´d appreciate any kind of help concerning this problem.

Thx in advance and greets
:wink: Pygma