SitePoint Sponsor

User Tag List

Results 1 to 1 of 1

Thread: hittest help

  1. #1
    SitePoint Member
    Join Date
    Sep 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hittest help

    hi guys,

    This is probably a fairly simple problem but i'm making a maze game and everything was working fine until i nested the game within a movie clip (name: movie1). Now the main character is able to walk through the maze walls. I have other hittests in the game were you pick stuff up and i was able to fix them by changing _root to _parent but that doesn't seem to work for the maze walls. Anyway here's the script and i've also included an example flash file. I'm new to flash and any help would be great

    onClipEvent(enterFrame) {
    if(Key.isDown(Key.UP)) {
    this._y -= 3;
    }
    else if(Key.isDown(Key.DOWN)) {
    this._y += 3;
    }
    if(Key.isDown(Key.LEFT)) {
    this._x -= 3;
    }
    else if(Key.isDown(Key.RIGHT)) {
    this._x += 3;
    }
    if(_root.maze.hitTest(_x+(_width/2),_y,true)) {
    this._x -= 3;
    }
    if(_root.maze.hitTest(_x-(_width/2),_y,true)) {
    this._x += 3;
    }
    if(_root.maze.hitTest(_x,_y+(_height/2),true)) {
    this._y -= 3;
    }
    if(_root.maze.hitTest(_x,_y-(_height/2),true)) {
    this._y += 3;
    }
    }
    Attached Files Attached Files


Bookmarks

Posting Permissions

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