PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] HitTestObject need help
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] HitTestObject need help

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    8

    resolved [RESOLVED] HitTestObject need help

    I have searched around but havent found any help for this problem so im gona ask here.

    In my game the player can create turrets, those turrets will be put into a array but my problem is that i dont want the player to be able to build 2 turrets or more on the same spot.

    this is what i have tried so far:
    Actionscript Code:
    function checkHit():void {
       for each (var square:Sprite in turretArray) {
          if (follow.hitTestObject(square)) {
              will=0;
          }
          else {
              will=1;
          }
       }
    }
    the problem is that it only checks against the latest made turret.
    lets say i make one turret then i cant build there. but when i make a secound one i can build on the first turret spot.

    anyone know how i can make my hittestobject check agains all turrets and only allow me to build if i dont hit any of them?

  2. #2
    Junior Member
    Join Date
    Jul 2010
    Posts
    8
    lol managed to solve it. Sometimes im just tried and dumb and spam forums for help ;(

    Actionscript Code:
    function checkHit():void {
        var hitted:int=0;
       for each (var square:Sprite in turretArray) {
          if (follow.hitTestObject(square)) {
              will=0;
              hitted=1;
          }
       }
       if(hitted==0) {
           will=1;
       }
    }

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