Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7856925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:51:57+00:00 2026-06-02T20:51:57+00:00

I have a basic space shooter game made in AS3. The game currently consists

  • 0

I have a basic space shooter game made in AS3.

The game currently consists out of one enemy and the player – a movable turret.

The premise of the game is, when the enemy is shot, it respawns, and the player score goes up with one point.

Now I want to extend the game by having more than one enemy on the playing field. The amount of enemies can differ for each wave, so I do not really want to keep track of them individually.

When I want to create an enemy, I call (from within my main class)

this.addChild(createNewEnemy());

with the createNewEnemy() function creating, and returning an anonymous Enemy object.

My question is, how do I perform hit tests on these anonymous Enemies with the bullet being fired by the player? When an enemy collides with a bullet, it should be removed and the score should be incremented.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:51:59+00:00Added an answer on June 2, 2026 at 8:51 pm

    I’m not quite sure what you mean by “anonymous object.” You really ought to be creating these things in such a way that can track them. One way would be perhaps override your addChild method for the container sprite and push new enemies to a vector. Example:

    var enemies:Vector.<Enemy> = new Vector.<Enemy>();
    
    override public function addChild(child:DisplayObject):DisplayObject
    {
        if(child is Enemy) {
           enemies.push(child);
        }
        super.addChild(child);
    }
    

    Now you can simply test against the enemies vector, or use the same “is” keyword in your bullet collision to check and see if the colliding display object is of based type Enemy.

    As far as the actual code to do the collision detection, see the following answer: https://stackoverflow.com/a/7083965/562566

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one basic doubt. I have a process which uses a shared library.
I have a problem compiling a program I made in BASIC. It's a DOS
I have a very basic regular expression that I just can't figure out why
I have a basic web hosting account through GoDaddy. It has plenty of space,
I have two vectors defining two separate points in a three-dimensional space. One is
I have a basic singleton class, similar to the one shown in the PHP
I have a basic layout that is one Div container wrapper and three columns
I have basic idea on Kilo Virtual Machine on Mobiles , I have clear
I have basic hello word example of Prime Faces. I have created dynamic web
I have a basic class that derived subclasses inherit from, it carries the basic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.