PDA

View Full Version : Fighting game


msentinelb
06-09-2002, 05:18 PM
I have made a fighter in flash that can punsh move and kick.
But now i need something to punch and kick at. maybe a second player. I have NO idea how to do this. can anybody help me???

CyanBlue
06-09-2002, 05:34 PM
You can always create new player who can get kicked and punched... :)

Jason

msentinelb
06-09-2002, 05:37 PM
Yeah ok, but the player2 must get hit when i punch ( or kick:) ) and i dont know how to do that. anyone a idea??

CyanBlue
06-09-2002, 09:29 PM
Hi...

Why don't you start with two blocks or something that will represent player1 and player2 and use hitTest or something to create the interaction and when you got this working, you can expand it to more complex objects???

Just my 2 cents...
Jason

msentinelb
06-10-2002, 11:32 AM
hmmm, yeah ok but what do you mean with hitest?

CyanBlue
06-10-2002, 09:49 PM
Um...

hitTest is one of the Flash's builtin function that can be used to do things like what you want to do...

Detailed info from the ActionScript Dictionary...
---
MovieClip.hitTest

Syntax

anyMovieClip.hitTest(x, y, shapeFlag);
anyMovieClip.hitTest(target);
Arguments

x The x coordinate of the hit area on the Stage.

y The y coordinate of the hit area on the Stage.

The x and y coordinates are defined in the global coordinate space.

target The target path of the hit area that may intersect or overlap with the instance specified by anyMovieClip. The target usually represents a button or text-entry field.

shapeFlag A Boolean value specifying whether to evaluate the entire shape of the specified instance (true), or just the bounding box (false). This argument can only be specified if the hit area is identified using x and y coordinate arguments.

Description

Method; evaluates the instance specified by anyMovieClip to see if it overlaps or intersects with the hit area identified by the target or x and y coordinate arguments.

Usage 1compares the x and y coordinates to the shape or bounding box of the specified instance, according to the shapeFlag setting. If shapeFlag is set to true, only the area actually occupied by the instance on the Stage is evaluated, and if x and y overlap at any point, a value of true is returned. This is useful for determining if the movie clip is within a specified hit, or hotspot, area.

Usage 2 evaluates the bounding boxes of the target and specified instance, and returns true if they overlap or intersect at any point.

Player

Flash 5 or later.

Example

The following example uses hitTest with the x_mouse and y_mouse properties to determine whether the mouse is over the target's bounding box:

if (hitTest( _root._xmouse, _root._ymouse, false));
The following example uses hitTest to determine if the movie clip ball overlaps or intersects with the movie clip square:

if(_root.ball, hittest(_root.square)){
trace("ball intersects square");
}
See also

MovieClip.localToGlobal
MovieClip.globalToLocal
MovieClip.getBounds
---