A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [help] really stuck, why is this not working!!

  1. #1
    IT'S GON' RAIN !!! var gotMilk's Avatar
    Join Date
    Apr 2004
    Location
    Yorkshire, England, UK
    Posts
    372

    [help] really stuck, why is this not working!!

    hi,

    here is my code i am using on my game character:

    code:

    onClipEvent (enterFrame) {
    if(Key.isDown(Key.LEFT)) {
    this._x -= 5;
    _root.alicemc.gotoAndPlay("left");
    }
    if(Key.isDown(Key.RIGHT)) {
    this._x += 5;
    _root.alicemc.gotoAndPlay("right");
    }
    if(Key.isDown(Key.UP)) {
    this._y -= 5;
    _root.alicemc.gotoAndPlay("up");
    }
    if(Key.isDown(Key.DOWN)) {
    this._y += 5;
    _root.alicemc.gotoAndPlay("down");
    }
    if(Key.isDown(Key.SPACE)) {
    _root.alicemc.gotoAndPlay("chop");
    }

    x = this._x;
    y = this._y;

    if(!_root.land.hitTest(this._x+x,this._y+y,true)) {
    _x += x;
    _y += y;
    }
    }

    onClipEvent (keyUp) {
    _root.alicemc.gotoAndStop(1);
    }



    it all works fine apart fom the hitTest, i am not very good with hitTest's and always get it wrong.
    Can anyone see what i have done wrong?

    the mc i am using for the hit has an instance name of "land".


    Please help.
    Ben.

    Professional quality freelance work done by Varstudios
    Visit us here http://www.varstudios.com/services



  2. #2
    flash mangler drunkenmaster2000's Avatar
    Join Date
    Apr 2001
    Location
    England
    Posts
    156
    try:

    if (hitTest(_root.land)) {
    etc.
    }

    Because the code is going on the _root.alice mc, the hitTest only needs to know what you are going to hit. In this case, _root.land

    As ever with me, this may be incorrect, but this is how I remember doing it.

    After checking the context help, it seems this is correct. fancy that

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