A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Stick to the plaform

  1. #1
    9 Times the Fun
    Join Date
    Oct 2002
    Location
    Mother Earth
    Posts
    183

    Stick to the plaform

    Hi all,
    Im in the process of making an art based side scrolling platform game. All has been well up until now when I decided to add a moving platform.
    The way the game works is the background is one large MC with a background image and a hidden MC with the platforms drawn on and it all scrolls as one. So for me too add a moving plaform I animated the platform inside an MC and placed it inside the drawn platforms MC. The moving platform then becomes part of hitest so my hero character is hiting the platform but it just moves from under him. I ran a search over the boards but nothing I can see will fix this problem. I though this would work but it doesn't:
    Code:
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.hero)) {
    		_root.hero._x = this._x;
    	}
    }
    dunno why this doesn't work but I cant seem to work it out.

    Any help appriciated,
    bk9

  2. #2
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    pretty hard, that one. art based is not an ideal solution for too interactive games like that...
    anyway, saying that i kept with art based method very long :-P

    maybe try:
    code:

    onClipEvent (load) {
    //speed of the platform
    speed = 2
    }
    onClipEvent (enterFrame) {
    if (this.hitTest(_root.hero._x, _root.hero._y, true)) {
    _root.hero._x += speed;
    }
    }



    if you want additional infos about that hitTest method, just look at the sticky thread... other than that, i don't know where are the _x=0 and _y=0 points of your character, you may need to add/change little things like
    code:
    this.hitTest(_root.hero._x, _root.hero._y+20, true)

    ...

    hope it helps

  3. #3
    9 Times the Fun
    Join Date
    Oct 2002
    Location
    Mother Earth
    Posts
    183
    Thanks Marmotte,
    Got it to work with your second bit of advice, prob is the way I wanted the platform to work was move left 'pause' then more right 'pause'. The hittest was a little dodgey so ill probably just leave it for now find somthing that will fuction better.

    Cheers,
    bk9

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