Class: Vector2

Vector2

so, this is strange I assume, there is a z.
But this z isn't a real axis, it's usefull to make a fake 3D scale on objects and
ordering GameObject by z + z-index (order is important, lower z will be under higher z of course)
So it's a Vector2 because you can't rotate or do anything on z axe, z is totally optional
(of course, you can produce really nice effects with z, by calculating collisions along z axis, you should be able to do a nice Street of Rage like)

new Vector2(x, y, z)

Parameters:
Name Type Argument Default Description
x Float <optional>
0
y Float <optional>
0
z Float <optional>
0
Source:
Example
 var pos = new DE.Vector2( 150, 100 );

Members

<private, static> _cosAngle :Float

store cosinus

Type:
  • Float
Source:

<private, static> _sinAngle :Float

store sinus

Type:
  • Float
Source:

<static> this.rotation :Float

current rotation, between 0 and 2PI

Type:
  • Float
Source:

<static> this.x :Float

Type:
  • Float
Source:

<static> this.y :Float

Type:
  • Float
Source:

<static> this.z :Float

Type:
  • Float
Source:

Methods

<static> this.dotProduct(a, b) → {Float}

return the dotProduct between two Vector
See wikipedia dot product for more informations

Parameters:
Name Type Description
a Vector2

first vector2

b Vector2

second vector2

Source:
Returns:

dotProduct result

Type
Float

<static> this.getAngle(a, b) → {Float}

return the angle (radians) between two vector2

Parameters:
Name Type Description
a Vector2

first vector2

b Vector2

second vector2

Source:
Returns:

angle result

Type
Float

<static> this.getHarmonics(rotation) → {Harmonics}

return the harmonics value
can pass a rotation to get harmonics with this rotation

Parameters:
Name Type Argument Description
rotation Float <optional>

used by gameObjects in getPos and other

Source:
Returns:

harmonics (cosinus and sinus)

Type
Harmonics

<static> this.getVector(a, b) → {Vector2}

return the Vector between two Vector2

Parameters:
Name Type Description
a Vector2

first vector2

b Vector2

second vector2

Source:
Returns:

this current instance

Type
Vector2

<static> this.isInRangeFrom(other, range) → {Boolean}

trigger a circle collision with an other Vector and a range

Parameters:
Name Type Description
other Vector2
range Float
Source:
Returns:

isInRange result

Type
Boolean

<static> this.multiply(coef) → {Vector2}

multiply this vector with coef

Parameters:
Name Type Description
coef Float
Source:
Returns:

this current instance

Type
Vector2

<static> this.normalize() → {Vector2}

change the vector length to 1 (check wikipedia normalize if you want know more about)

Source:
Returns:

this current instance

Type
Vector2

<static> this.rotate(angle, ignoreDelta) → {Float}

apply the given angle to rotation

Parameters:
Name Type Argument Description
angle Float

rotation value

ignoreDelta Boolean <optional>

if you want to prevent deltaTime adjustment

Source:
Returns:

this.rotation current rotation

Type
Float

<static> this.setPosition(Vector2) → {Vector2}

set precise position

Parameters:
Name Type Description
Vector2 Vector2 | Float

or x

Source:
Returns:

this current instance

Type
Vector2

<static> this.setRotation(newAngle) → {Float}

set precise rotation

Parameters:
Name Type Description
newAngle Float
Source:
Returns:

this.rotation current rotation

Type
Float

<static> this.translate(vector2, absolute, ignoreDelta) → {Vector2}

move position along the given Vector2

Parameters:
Name Type Argument Description
vector2 Vector2

vector to translate along

absolute Boolean

if absolute, translation will ignore current rotation

ignoreDelta Boolean <optional>

if you want to prevent deltaTime adjustment

Source:
Returns:

this current instance

Type
Vector2
Dreamirl Copyright © 2014 And the contributors
Documentation generated by JSDoc 3.2.2 on Thu Apr 24 2014 11:56:41 GMT+0200 (CEST) using the DocStrap template.