Flash actionscript help

3 posts

Flag Post

Ok I have this a code that me and my friend ended up with now I can make a ball move easy but Im not sure how to make a stickmen using the key directions now my friend mainly knows the actionscript so this is basically what I want to do

1.Take out up and down keys and just go left and right

2.I can make a stickman animation but how do I make the option where if I hold right key down he runs I already tried

Ok here is the code

onClipEvent (load) {
	power = 3;
	radius = 6;
	_x = 35;
	_y = 40;
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.LEFT)) {
		_x -= power;
	}
	if (Key.isDown(Key.RIGHT)) {
		_x += power;
	}
	if (Key.isDown(Key.UP)) {
		_y -= power;
	}
	if (Key.isDown(Key.DOWN)) {
		_y += power;
	}
	while (_root.wall.hitTest(_x, _y+radius, true)) {
		_y--;
	}
	while (_root.wall.hitTest(_x, _y-radius, true)) {
		_y++;
	}
	while (_root.wall.hitTest(_x-radius, _y, true)) {
		_x++;
	}
	while (_root.wall.hitTest(_x+radius, _y, true)) {
		_x--;
	}
	if ((_root.cop.hitTest(_x, _y+radius, true)) or (_root.cop.hitTest(_x, _y-radius, true)) or (_root.cop.hitTest(_x+radius, _y, true)) or (_root.cop.hitTest(_x-radius, _y, true))) {
		_x = 35;
		_y = 40;
	}
}

I also have a wall so some of that is for the wall

 
Flag Post

Mockster, I’m sorry, but I’m finding it a little hard to determine what your problem is. If all you need is a way to make a movieclip move left and right you might want to check out the last few forum posts. Someone had a link to a tutorial that I think shows something similar to what you want, and I also recently posted an example that will move a movieclip left and right.

Let me know if you have any problems.

 
Flag Post

Basically my main thing is that I have a
ball and can mkae him move but how do I add the animation to make him run I already have layers of him running and looped it but how do I add this?