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 6773371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:39:38+00:00 2026-05-26T15:39:38+00:00

I am currently building a game, where u have controllers which you can move

  • 0

I am currently building a game, where u have controllers which you can move around and are connected one to another by lines, and the lines need to collide with all the eggs on the screen to go to the next level. Also, whenever an egg collides with a line, the egg changes its colour.

The thing is, I have about 10 eggs and 7 lines, and getting the conditionals for checking if the egg is touched by a line, and if all the eggs are touched by lines, is A LOT (I mean seriously a lot I’ve already tried it) of code.

Its just stacking HUNDREDS of conditionals and event listeners together.

Does anybody have a prettier solution?
Thnx for any comments 😀

  • 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-05-26T15:39:39+00:00Added an answer on May 26, 2026 at 3:39 pm

    You could use nested for loops to check on enterframe event. This could eat up the processor, so make sure you only run the loop when necessary.

    Here is a simple example of the nested loop:

    var eggs:Array = [e0,e1,e2,e3,e4,e5,e6,e7,e8,e9];
    var lines:Array = [l0,l1,l2,l3,l4,l5,l6];
    var eggLen:int = eggs.length;
    var lineLen:int  = lines.length;
    var egg:MovieClip;
    var line:MovieClip;
    
    addEventListener(Event.ENTER_FRAME, enterFrameHandler);
    
    function enterFrameHandler(e:Event):void {
        EggLoop:for (var i:int = 0; i<eggLen; i++) {
            egg = eggs[i];
            LineLoop:for (var j:int = 0; j<lineLen; j++) {
                line = lines[j];
                if (egg.hitTestObject(line)) {
                    trace("Egg: " + egg + " just hit Line: " + line);
                    break LineLoop;
                    // if you want to break the entire loop use:
                    // break EggLoop;
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently building a game with cocos2d and I have the following Problem: I
I'm currently building a game for the iPhone with cocos2d and have the following
With reference to this programming game I am currently building. I have a Class
I'm currently working on building a game which is on a planet, the way
I have a fairly simple board game i've been building in C++. Currently, players
I am currently building in Version 3.5 of the .Net framework and I have
I'm currently building a tool for my game engine using WPF. The tool is
Currently, I'm building a game with pure UIKit. It's a game where some character
I am currently building a game in phonegap using jQuery Mobile frame work. What
I am currently building a multiplayer system, and I have a design question about

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.