1. 80
posts
Registered User

## City Game

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

2. 557
posts
Block user.
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.

3. 80
posts
Registered User
thanks, but what is the distance formula?

4. 80
posts
Registered User

## An example

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

5. Originally Posted by BiGg RiE
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. 557
posts
Block user.
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) );`

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

8. 557
posts
Block user.
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.

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

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
•