Game Programming II - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

Game Programming II

Description:

Game Programming II. MULT 120. Collisions in Flash. hitTest Method. MovieClip.hitTest ... hitArea method. MovieClip.hitArea. Availability. Flash Player 6. ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 5
Provided by: kathleen82
Category:
Tags: game | programming

less

Transcript and Presenter's Notes

Title: Game Programming II


1
Game Programming II
  • MULT 120
  • Collisions in Flash

2
hitTest Method
  • MovieClip.hitTest()
  • Usage
  • my_mc.hitTest(xNumber, yNumber,
    shapeFlagBoolean) Boolean my_mc.hitTest(target
    Object) Boolean
  • Parameters
  • 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 my_mc. The target parameter 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 parameter can be specified only if
    the hit area is identified using x and y
    coordinate parameters.
  • Returns
  • A Boolean value of true if my_mc overlaps with
    the specified hit area, false otherwise.

3
hitTest Method Examples
  • x _root._xmouse
  • y _root._ymouse
  • if (myClip_mc.hitTest(x, y, true)
  • trace(hit the shape)
  • if (myClip_mc.hitTest(x, y, false)
  • trace(hit within the bounding box)
  • if (myClip_mc.hitTest(otherObject)
  • trace(hit within the bounding box)
  • sample file

4
hitArea method
  • MovieClip.hitArea
  • Availability
  • Flash Player 6.
  • Usage
  • my_mc.hitAreaObject
  • Returns
  • A reference to a movie clip.
  • Description
  • Property designates another movie clip to serve
    as the hit area for a movie clip. If the hitArea
    property does not exist or is null or undefined,
    the movie clip itself is used as the hit area.
    The value of the hitArea property may be a
    reference to a movie clip object.
  • You can change the hitArea property at any time
    the modified movie clip immediately takes on the
    new hit area behavior. The movie clip designated
    as the hit area does not need to be visible its
    graphical shape, although not visible, is
    hit-tested. The hitArea property can be read out
    of a prototype object.
Write a Comment
User Comments (0)
About PowerShow.com