Bottle 2D - Lua API 1.0.0
All you need to create games using bottle2D.
Public Member Functions | Public Attributes

Group Class Reference

A Group is a container wich can contain drawable and physic object. More...

#include <header.hpp>

Inheritance diagram for Group:
Drawable Object Screen

List of all members.

Public Member Functions

Group Clone ()
 Create a clone of the object and return an handler to the clone.
Group CloneToGroup (Group newParent)
 Create a clone of the object, change the parent and return an handler to the clone.
nil SetScale (Vector2D scale)
 Set the group scale.
Vector2D GetScale ()
 Get the group scale.
number GetChildCount ()
 Return the number of physic and drawable children that this group contains.
PhysicObject GetPhysicChild (number id)
 Return the physic child number id.
number GetPhysicChildCount ()
 Return the number of physic children that this group contains.
Drawable GetDrawableChild (number id)
 Return the drawable child number id.
number GetDrawableChildCount ()
 Return the number of drawable children that this group contains.
nil DestroyChildren ()
 Destroy every children of the group.
nil EnableCut (bool isCut)
 Enable / disable the cutting of a certain part of the group.
bool IsCut ()
 Return true if the cutting is enabled, false otherwise.
nil SetCutRect (Vector2D position, Vector2D size)
 Set the cut rectangle.
Vector2D GetCutRectPosition ()
 Get the cut rectangle's position.
Vector2D GetCutRectSize ()
 Get the cut rectangle's size.
luaObject GetChildTable ()
 Get a lua table containing all its childs.
luaObject FindByIndex (number id)
 Get a child from its index in the group (a number for 1 to Group::GetChildCount().
luaObject FindByName (string name)
 Find an object in the group with its name and cast it with the good type.
PhLine FindByNamePhLine (string name)
 Find an object in the group with its name.
PhRect FindByNamePhRect (string name)
 Find an object in the group with its name.
PhTriangle FindByNamePhTriangle (string name)
 Find an object in the group with its name.
PhCircle FindByNamePhCircle (string name)
 Find an object in the group with its name.
PhShape FindByNamePhShape (string name)
 Find an object in the group with its name.
Group FindByNameGroup (string name)
 Find an object in the group with its name.
ParticleSource FindByNameParticleSource (string name)
 Find an object in the group with its name.
Shape FindByNameShape (string name)
 Find an object in the group with its name.
Sprite FindByNameSprite (string name)
 Find an object in the group with its name.
Text FindByNameText (string name)
 Find an object in the group with its name.
PostFX FindByNamePostFX (string name)
 Find an object in the group with its name.
Screen FindByNameScreen (string name)
 Find an object in the group with its name.
ScreenRenderer FindByNameScreenRenderer (string name)
 Find an object in the group with its name.
PhLine CreatePhLine (number phGroupId, string name, Vector2D pt1, Vector2D pt2)
 Create a new physic line and attach it to this group.
PhRect CreatePhRect (number phGroupId, string name, Vector2D size)
 Create a new physic rectangle and attach it to this group.
PhTriangle CreatePhTriangle (number phGroupId, string name, Vector2D pt1, Vector2D pt2, Vector2D pt3)
 Create a new physic triangle and attach it to this group.
PhShape CreatePhShape (number phGroupId, string name)
 Create a physic shape and attach it to this group.
PhCircle CreatePhCircle (number phGroupId, string name, Vector2D center, number radius)
 Create a new physic disk and attach it to this group.
Group CreateGroup (string name)
 Create a Group object and add it to the current group.
ParticleSource CreateParticleSource (string name, ParticleModel model, number maxParticleNumber)
 Create a ParticleSource object and add it to the current group.
Shape CreateShape (string name)
 Create a Shape object and add it to the current group.
Shape CreateShapeLine (string name, Vector2D P1, Vector2D P2, number Thickness, Color Col, number Outline, Color OutlineCol)
 Create a shape, initialise it as a line and add it to the current group.
Shape CreateShapeRectangle (string name, Vector2D P1, Vector2D P2, Color Col, number Outline, Color OutlineCol)
 Create a shape, initialise it as a rectangle and add it to the current group.
Shape CreateShapeCircle (string name, Vector2D Center, number Radius, Color Col, number Outline, Color OutlineCol)
 Create a circle / disk, initialise it as a rectangle and add it to the current group.
Sprite CreateSprite (string name)
 Create a Sprite object and add it to the current group.
Text CreateText (string name, string text)
 Create a Text object and add it to the current group.
PostFX CreatePostFX (string name)
 Create a PostFX object and add it to the current group.
ScreenRenderer CreateScreenRenderer (string name)
 Create a ScreenRenderer object and add it to the current group.
nil RegisterEventAutoRemoveOnDestroy (EventHandlerBase event)

Public Attributes

Vector2D scale
 Edit scale.

Detailed Description

A Group is a container wich can contain drawable and physic object.

When a group is moved or rotated, its child will be moved or rotated too. It's like a folder: if you Destroy it, its children will be destroyed too. It could be created using Group::CreateGroup.


Member Function Documentation

Group Group::Clone ( )

Create a clone of the object and return an handler to the clone.

Reimplemented from Object.

Group Group::CloneToGroup ( Group  newParent)

Create a clone of the object, change the parent and return an handler to the clone.

Reimplemented from Object.

Group Group::CreateGroup ( string  name)

Create a Group object and add it to the current group.


Parameters:
nameThe name of the object.
Returns:
The created object.
ParticleSource Group::CreateParticleSource ( string  name,
ParticleModel  model,
number  maxParticleNumber 
)

Create a ParticleSource object and add it to the current group.


Parameters:
nameThe name of the object.
modelThe particle model for this ParticleSource.
maxParticleNumberUsed to reserve memory. It should not be oversized (unusefull memory would be allocated) or undersized (some particle won't be created)

  • If your particle source just has a flow and an unlimited tank, then maxParticleNumber should be flow * maxLifeTime.
  • If your particle is an explosion, and all particle are dead before starting a new explosion, then maxParticleNumber should be tank.
Returns:
The created object.
PhCircle Group::CreatePhCircle ( number  phGroupId,
string  name,
Vector2D  center,
number  radius 
)

Create a new physic disk and attach it to this group.


Parameters:
phGroupIdThe physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()).
nameThe name of the object.
centerThe center of the circle. Can be changed with Object::SetPosition().
radiusThe radius of the disk.
Returns:
The created object.
PhLine Group::CreatePhLine ( number  phGroupId,
string  name,
Vector2D  pt1,
Vector2D  pt2 
)

Create a new physic line and attach it to this group.


Parameters:
phGroupIdThe physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()).
nameThe name of the object.
pt1First point of the line.
pt2Second point of the line.
Returns:
The created object.
PhRect Group::CreatePhRect ( number  phGroupId,
string  name,
Vector2D  size 
)

Create a new physic rectangle and attach it to this group.


Parameters:
phGroupIdThe physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()).
nameThe name of the object.
sizeThe size of the rectangle. Use Object::SetPosition() to change the object's position.
Returns:
The created object.
PhShape Group::CreatePhShape ( number  phGroupId,
string  name 
)

Create a physic shape and attach it to this group.


When a shape is created, you can add points to it by calling PhShape::AddPoint(). The shape must be convex !

Parameters:
phGroupIdThe physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()).
nameThe name of the object.
Returns:
The created object.
PhTriangle Group::CreatePhTriangle ( number  phGroupId,
string  name,
Vector2D  pt1,
Vector2D  pt2,
Vector2D  pt3 
)

Create a new physic triangle and attach it to this group.


Parameters:
phGroupIdThe physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()).
nameThe name of the object.
pt1First point of the triangle.
pt2Second point of the triangle.
pt3Third point of the triangle.
Returns:
The created object.
PostFX Group::CreatePostFX ( string  name)

Create a PostFX object and add it to the current group.


Parameters:
nameThe name of the object.
Returns:
The created object.
ScreenRenderer Group::CreateScreenRenderer ( string  name)

Create a ScreenRenderer object and add it to the current group.


Parameters:
nameThe name of the object.
Returns:
The created object.
Shape Group::CreateShape ( string  name)

Create a Shape object and add it to the current group.


Parameters:
nameThe name of the object.
Returns:
The created object.
Shape Group::CreateShapeCircle ( string  name,
Vector2D  Center,
number  Radius,
Color  Col,
number  Outline,
Color  OutlineCol 
)

Create a circle / disk, initialise it as a rectangle and add it to the current group.


Parameters:
nameThe name of the object.
CenterPosition of the center
RadiusRadius
ColColor used to fill the circle
OutlineOutline width
OutlineColColor used to draw the outline
Returns:
The created object.
Shape Group::CreateShapeLine ( string  name,
Vector2D  P1,
Vector2D  P2,
number  Thickness,
Color  Col,
number  Outline,
Color  OutlineCol 
)

Create a shape, initialise it as a line and add it to the current group.


Parameters:
nameThe name of the object.
P1Position of the first point
P2Position second point
ThicknessLine thickness
ColColor used to draw the line
OutlineOutline width (0 by default)
OutlineColColor used to draw the outline
Returns:
The created object.
Shape Group::CreateShapeRectangle ( string  name,
Vector2D  P1,
Vector2D  P2,
Color  Col,
number  Outline,
Color  OutlineCol 
)

Create a shape, initialise it as a rectangle and add it to the current group.


Parameters:
nameThe name of the object.
P1Position of the first point
P2Position second point
ColColor used to fill the rectangle
OutlineOutline width
OutlineColColor used to draw the outline
Returns:
The created object.
Sprite Group::CreateSprite ( string  name)

Create a Sprite object and add it to the current group.


Parameters:
nameThe name of the object.
Returns:
The created object.
Text Group::CreateText ( string  name,
string  text 
)

Create a Text object and add it to the current group.


Parameters:
nameThe name of the object.
textText of the object.
Returns:
The created object.
nil Group::DestroyChildren ( )

Destroy every children of the group.

nil Group::EnableCut ( bool  isCut)

Enable / disable the cutting of a certain part of the group.

Use Group::SetCutRect to define that part.

luaObject Group::FindByIndex ( number  id)

Get a child from its index in the group (a number for 1 to Group::GetChildCount().


Warning: no particular order are warranted. Use Group::GetChildTable() to traverse a whole group : it will be faster.

luaObject Group::FindByName ( string  name)

Find an object in the group with its name and cast it with the good type.

Return nil if the object doesn't exist.

Group Group::FindByNameGroup ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ParticleSource Group::FindByNameParticleSource ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

PhCircle Group::FindByNamePhCircle ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

PhLine Group::FindByNamePhLine ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

PhRect Group::FindByNamePhRect ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

PhShape Group::FindByNamePhShape ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

PhTriangle Group::FindByNamePhTriangle ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

PostFX Group::FindByNamePostFX ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

Screen Group::FindByNameScreen ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ScreenRenderer Group::FindByNameScreenRenderer ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

Shape Group::FindByNameShape ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

Sprite Group::FindByNameSprite ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

Text Group::FindByNameText ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

number Group::GetChildCount ( )

Return the number of physic and drawable children that this group contains.

luaObject Group::GetChildTable ( )

Get a lua table containing all its childs.


Warning: no particular order are warranted.

Vector2D Group::GetCutRectPosition ( )

Get the cut rectangle's position.

Vector2D Group::GetCutRectSize ( )

Get the cut rectangle's size.

Drawable Group::GetDrawableChild ( number  id)

Return the drawable child number id.

number Group::GetDrawableChildCount ( )

Return the number of drawable children that this group contains.

PhysicObject Group::GetPhysicChild ( number  id)

Return the physic child number id.

number Group::GetPhysicChildCount ( )

Return the number of physic children that this group contains.

Vector2D Group::GetScale ( )

Get the group scale.

bool Group::IsCut ( )

Return true if the cutting is enabled, false otherwise.

nil Group::RegisterEventAutoRemoveOnDestroy ( EventHandlerBase  event)
nil Group::SetCutRect ( Vector2D  position,
Vector2D  size 
)

Set the cut rectangle.

You should enable cutting.

nil Group::SetScale ( Vector2D  scale)

Set the group scale.

It allows you to modify the size of a single group and its childs.


Member Data Documentation

Edit scale.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables