Be a Supporter!

Solid object? [AS2]

  • 358 Views
  • 2 Replies
New Topic Respond to this Topic
stickman8190
stickman8190
  • Member since: Mar. 7, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Solid object? [AS2] 2012-05-25 13:23:58 Reply

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?


also click Here to view my profile at jiggmin.com

BBS Signature
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to Solid object? [AS2] 2012-05-25 14:03:06 Reply

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
Response to Solid object? [AS2] 2012-05-26 16:33:02 Reply

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!


also click Here to view my profile at jiggmin.com

BBS Signature