Director Help

spriteSpaceToWorldSpace

Usage

sprite(whichSprite).camera.spriteSpaceToWorldSpace(loc)
sprite(whichSprite).camera(index).spriteSpaceToWorldSpace(loc)

Description

3D command; returns a world-space position that is found on the specified camera’s projection plane that corresponds to a location within the referenced sprite.

The projection plane is defined by the camera's X and Y axes, and is at a distance in front of the camera such that one pixel represents one world unit of measurement. It is this projection plane that is used for the sprite display on stage.

The camera.spriteSpaceToWorldSpace() form of this command is a shortcut for using camera(1).spriteSpaceToWorldSpace().

All cameras that are used by the referenced sprite will respond to the spriteSpaceToWorldSpace command as if their display rect is the same size as the sprite.

Parameters

loc Required. Specifies the location in the referenced sprite. This location should be a point relative to the sprite’s upper-left corner.

Example

This statement shows that the point (50, 50) within sprite 5 is equivalent to the vector (-1993.6699, 52.0773, 2263.7446) on the projection plane of the camera of sprite 5:

-- Lingo
put sprite(5).camera.spriteSpaceToWorldSpace(point(50, 50))
-- vector(-1993.6699, 52.0773, 2263.7446)

// Javascript
put (sprite(5).camera.spriteSpaceToWorldSpace(point(50, 50)) );
//<vector(-1993.6699, 52.0773, 2263.7446)>

See also

worldSpaceToSpriteSpace, rect (camera), camera