0 Replies - 466 Views - Last Post: 22 February 2009 - 05:11 PM

#1 ryrocks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-February 09

classic platform problem

Post icon  Posted 22 February 2009 - 05:11 PM

I have a character on the stage (_ball_mc) which you control with the arrow keys. I also have a rectangle movieclip on the stage (this). I want this rectangle movieclip to act as a block platform. ie. When the character jumps ontop of it he can walk across it, if he walks into it from the left he cant move left any further, same with the right side.

These movieclips are not being created at runtime, they are on the stage.

My registration point of the character is bottom right,
my registration point of the block is top left

I've used the following ENTERFRAME with not much luck. Stopping the character from moving any further when he walks into the block seems to be ok. I'm having trouble getting him to land on the block without conflicting with the leftDown and rightDown.

As this is such a common gaming element, I figure there must be some documentation on this ?

if (_findStageInstances)
				_ball_mc = parent.getChildByName("ball_mc") as MovieClip;
				_findStageInstances = false;
			if (_ball_mc.hitTestObject(this) && _ball_mc.x >this.x)
				_ball_mc.rightDown = false;
			if (_ball_mc.hitTestObject(this) && _ball_mc.x > (this.x + this.width))
				_ball_mc.leftDown = false;
				_ball_mc.x +=1; //move ball away from block, otherwise Rdown and Ldown are disabled and it gets stuck
			if (_ball_mc.hitTestObject(this) && _ball_mc.y < this.y)
				_ball_mc.falling = false;
				_ball_mc.jump = false;
				_ball_mc.y = (this.y);

Any help would be much appreciated!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1