A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Platform game

  1. #1
    Senior Member
    Join Date
    Aug 2007
    Posts
    100

    Platform game

    I have attached the fla. At the moment the bg moves when the arrow keys are pressed and the hero jumps. But what I would like to know is how to make it so that the ball lands on anything in the platform movieclip.

    Here is the actionscript:

    Code:
    onClipEvent (load) {
    	speed = 4;
    	isJumping = false;
    	jumpSpeed = 0;
    	startY = _root.bg._y;
    }
    onClipEvent (enterFrame) {
    	if (isJumping) {
    		_y += jumpSpeed;
    		jumpSpeed += 1;
    		if (_y>=startY) {
    			_y = startY;
    			isJumping = false;
    			speed = 6;
    		}
    	} else {
    		if (Key.isDown(Key.SPACE)) {
    			isJumping = true;
    			jumpSpeed = -20;
    			speed = 6;
    		}
    	}
    	if (Key.isDown(Key.LEFT)) {
    		_root.bg._x += speed;
    		_xscale = -100;
    	}
    	if (Key.isDown(Key.RIGHT)) {
    		_root.bg._x -= speed;
    		_xscale = 100;
    	}
    }
    Attached Files Attached Files

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    search for hitTest in this forum - or even better search in the games section. There should also be a sticky there with lots of resources regarding that.
    goto http://board.flashkit.com/board/showthread.php?t=518121

  3. #3
    Junior Member
    Join Date
    Mar 2008
    Posts
    25
    The game was slooow. Up the frame rate to 25fps. I'm new to flash too - but it sounds to me like collision is actually handled by flash itself - lucky as in JavaScript you have to do it all yourself using bounding boxes etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center