Results 1 to 5 of 5

Thread: hitTest on duplicated MovieClips

  1. #1
    3
    posts
    Registered User

    hitTest on duplicated MovieClips

    In my as2 game i have an enemy on stage called "Enemy0", my script duplicates this enemys' actions and spawns a var number of enemies called "Enemy". However when i play the game my "Enemy0" hits the wall I made while my "Enemy" ignores the hitTest and goes through it.

    How do i make it so that my "Enemy0" and my duplicated enemy, "Enemy", hit the wall? I can upload my flash or show my code if need be.

    Plz help and thanks in advance for any help.
    Last edited by Acon; May 1st, 2012 at 11:47 AM.

  2. #2
    3
    posts
    Registered User
    Plz help me.

    this problem is driving me insane

  3. #3
    you need to post your code

    you have a scope issue

  4. #4
    3
    posts
    Registered User
    the following code is to copy my "enemy0";

    var nrEnemies = 2;
    for(i=1; i<nrEnemies; i++)
    {
    _root.Enemy0.duplicateMovieClip("Enemy" +i, _root.getNextHighestDepth());
    }

    the following is my code for my "enemy0"

    onClipEvent(load)
    {
    function reset()
    {
    var timer = 12;
    this._y = Math.random() * 300
    this._x = 1000
    mySpeed = Math.ceil(Math.random() * 6) + 6;
    }
    reset();
    }

    onClipEvent(enterFrame)
    {
    //in every frame the enemy move left in the speed defined in the reset function.
    this._x -= mySpeed;
    if (this._x < -10)
    {
    //if the enemy is not on the screen, we reset it.
    reset();
    }
    //if our timer is bigger than 12 we get a new
    if (timer >= 12)
    {
    //direction to the Ship.
    var dir = Math.ceil(Math.random() * 2)
    //We get a random number, 1 or 2. 1 is up, 2 is down.
    //Then we set timer to 0, so we only get a new dir when timer is bigger than 12
    timer = 0;
    }
    if (dir == 1)
    {
    //if dir = 1, we move the ship up.
    this._y -= 3;
    } else if(dir == 2)
    {
    //if dir = 2, we move the ship down.
    this._y += 3;
    }
    //increase timer by 1, so the timer gets equal to 12 and we get a new direction.
    timer++
    }

    onClipEvent(enterFrame)
    {
    if (_root.lives <= 0)
    {
    this.removeMovieClip();
    }
    }

    and the following is the code for my wall

    onClipEvent(enterFrame)
    {
    if(this.hitTest(_root.Ship))
    {
    _root.Ship._y += 10;
    }
    }

    onClipEvent(enterFrame)
    {
    if(this.hitTest(_root.Enemy0))
    {
    _root.Enemy0._y += 10;
    }
    }

  5. #5
    Hi..
    need some help in flash
    in as2
    i want to play movie clips as per the time
    ex .
    1mc = 9.00 to 11.00
    2mc = 12.00 to 16.00


    and so..




    plzzzzz
    i hav written some code this not working prpoerly


    some help would be gr8 for me thks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012