Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 9 of 9

Thread: City Game

  1. #1

    City Game

    i need
    Last edited by BiGg RiE; September 18th, 2008 at 10:11 AM.

  2. #2
    Umm...

    This sounds like a fairly simple point & click type thing right? Set up each city to be a button or a movie clip, and put them in a container clip. Add a CLICK listener to the container that checks which clip has been targeted. if the user doesn't click the correct city, use the distance formula to calculate the distance from the mouse click to the correct city & do whatever you want after that.

    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  3. #3
    thanks, but what is the distance formula?

  4. #4

    An example

    Here's an example
    Last edited by BiGg RiE; September 18th, 2008 at 10:11 AM.

  5. Quote Originally Posted by BiGg RiE View Post
    thanks, but what is the distance formula?
    Depends on how much of a sphere your map is. I guess the simple Pythagoras algorithm is sufficient.

  6. #6
    The distance formula measures the distance between 2 points. It's based upon the Pythagorean Theorem - the relationship of the sides of a right-triangle.

    // Whereas A, B, and C are the lengths of each side and C is the hypotenuse.
    A squared + B squared = C squared

    Anyhow, you'll tweak that to get to the distance formula you'd use in flash:

    Code:
    Distance = Math.sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
    EDIT: Google is your friend
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  7. #7
    Ok, so
    Last edited by BiGg RiE; September 18th, 2008 at 10:11 AM.

  8. #8
    1. Math.ceil() and Math.floor() will round your numbers. ceil rounds up, floor rounds down.
    Usage: var roundedDistance = Math.ceil( myDecimalNumberTobeRounded );

    2. I'll maybe post your code to your project on here later
    Last edited by therobot; July 3rd, 2008 at 01:37 PM.
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  9. #9
    Ok, I'm
    Last edited by BiGg RiE; September 18th, 2008 at 10:12 AM.

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