Description

Define the polygon as a rectangle. The element will take up his new dimensions (width and height properties). If x and y are undefined, they will default 0. If only one parameter is defined, the shape is a square with the given width

Usage

Parameters

  • x {Integer}

    Position X

  • y {Integer} optional

    (optional) Position Y

  • w {Integer} optional

    (optional) Width

  • h {Integer} optional

    (optional) Height

Example

In ready method

 var entity = Class.New("Entity", [stage]);
 entity.rect(0, 0, 100, 100);
 // entity.rect(100, 100);  => equivalent
 // entity.rect(100);       => equivalent

Other example

 var entity = Class.New("Entity", [stage]);
 entity.rect(100, 300);
 // entity.rect(0, 0, 100, 300); => equivalent

Discussion