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

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.
luaObject GetPhysicChild (number index)
 Return the physic child with the given index.
number GetPhysicChildCount ()
 Return the number of physic children that this group contains.
luaObject GetDrawableChild (number index)
 Return the drawable with the given index.
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.
ProtectedPtr< PhLineFindByNamePhLine (string name)
 Find an object in the group with its name.
ProtectedPtr< PhRectFindByNamePhRect (string name)
 Find an object in the group with its name.
ProtectedPtr< PhTriangleFindByNamePhTriangle (string name)
 Find an object in the group with its name.
ProtectedPtr< PhCircleFindByNamePhCircle (string name)
 Find an object in the group with its name.
ProtectedPtr< PhShapeFindByNamePhShape (string name)
 Find an object in the group with its name.
ProtectedPtr< GroupFindByNameGroup (string name)
 Find an object in the group with its name.
ProtectedPtr< ParticleSourceFindByNameParticleSource (string name)
 Find an object in the group with its name.
ProtectedPtr< ShapeFindByNameShape (string name)
 Find an object in the group with its name.
ProtectedPtr< SpriteFindByNameSprite (string name)
 Find an object in the group with its name.
ProtectedPtr< TextFindByNameText (string name)
 Find an object in the group with its name.
ProtectedPtr< PostFXFindByNamePostFX (string name)
 Find an object in the group with its name.
ProtectedPtr< ScreenFindByNameScreen (string name)
 Find an object in the group with its name.
ProtectedPtr< ScreenRendererFindByNameScreenRenderer (string name)
 Find an object in the group with its name.
ProtectedPtr< TexturedAreaFindByNameTexturedArea (string name)
 Find an object in the group with its name.
ProtectedPtr< PhLineCreatePhLine (number phGroupId, string name, Vector2D pt1, Vector2D pt2)
 Create a new physic line and attach it to this group.
ProtectedPtr< PhRectCreatePhRect (number phGroupId, string name, Vector2D size)
 Create a new physic rectangle and attach it to this group.
ProtectedPtr< PhRectCreatePhRect (number phGroupId, string name, Vector2D position, Vector2D size)
 Create a new physic rectangle and attach it to this group.
ProtectedPtr< PhTriangleCreatePhTriangle (number phGroupId, string name, Vector2D pt1, Vector2D pt2, Vector2D pt3)
 Create a new physic triangle and attach it to this group.
ProtectedPtr< PhShapeCreatePhShape (number phGroupId, string name)
 Create a physic shape and attach it to this group.
ProtectedPtr< PhCircleCreatePhCircle (number phGroupId, string name, Vector2D center, number radius)
 Create a new physic disk and attach it to this group.
ProtectedPtr< GroupCreateGroup (string name)
 Create a Group object and add it to the current group.
ProtectedPtr< GroupCreateGroup (string name, Vector2D position)
 Create a Group object and add it to the current group.
ProtectedPtr< ParticleSourceCreateParticleSource (string name, ParticleModel model, number maxParticleNumber)
 Create a ParticleSource object and add it to the current group.
ProtectedPtr< ShapeCreateShape (string name)
 Create a Shape object and add it to the current group.
ProtectedPtr< ShapeCreateShapeLine (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.
ProtectedPtr< ShapeCreateShapeRectangle (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.
ProtectedPtr< ShapeCreateShapeRectangleSize (string name, Vector2D position, Vector2D size, Color Col, number Outline, Color OutlineCol)
 Create a shape, initialise it as a rectangle and add it to the current group.
ProtectedPtr< ShapeCreateShapeCircle (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.
ProtectedPtr< SpriteCreateSprite (string name)
 Create a Sprite object and add it to the current group.
ProtectedPtr< SpriteCreateSprite (string name, Texture image, Vector2D position)
 Create a Sprite object and add it to the current group.
ProtectedPtr< TextCreateText (string name, string text)
 Create a Text object and add it to the current group.
ProtectedPtr< TextCreateText (string name, string text, number fontSize, Color fontColor, Vector2D position)
 Create a Text object and add it to the current group.
ProtectedPtr< PostFXCreatePostFX (string name)
 Create a PostFX object and add it to the current group.
ProtectedPtr< ScreenRendererCreateScreenRenderer (string name)
 Create a ScreenRenderer object and add it to the current group.
ProtectedPtr< TexturedAreaCreateTexturedArea (string name, Texture image, Vector2D position, Vector2D areaSize)
 Create a TexturedArea object and add it to the current group.
nil SetPreDestroyFunction (luaObject luaFunction)
 Register an event to the group so that it will be destroyed when the group is destroyed.
luaObject GetPreDestroyFunction ()
 Get the pre destroy function associated to this group.

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

ProtectedPtr<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.
ProtectedPtr<Group> Group::CreateGroup ( string  name,
Vector2D  position 
)

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


Parameters:
nameThe name of the object.
positionThe position of the object.
Returns:
The created object.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<PhRect> Group::CreatePhRect ( number  phGroupId,
string  name,
Vector2D  position,
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.
positionThe position of the rectangle.
sizeThe size of the rectangle.
Returns:
The created object.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<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.
ProtectedPtr<Shape> Group::CreateShapeRectangleSize ( string  name,
Vector2D  position,
Vector2D  size,
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.
positionPosition of the first point
sizeThe size of the rectangle
ColColor used to fill the rectangle
OutlineOutline width
OutlineColColor used to draw the outline
Returns:
The created object.
ProtectedPtr<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.
ProtectedPtr<Sprite> Group::CreateSprite ( string  name,
Texture  image,
Vector2D  position 
)

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


Parameters:
nameThe name of the object.
imageThe Texture of the sprite.
positionThe position of the object.
Returns:
The created object.
ProtectedPtr<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.
ProtectedPtr<Text> Group::CreateText ( string  name,
string  text,
number  fontSize,
Color  fontColor,
Vector2D  position 
)

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


Parameters:
nameThe name of the object.
textText of the object.
fontSizeThe font size of the displayed text.
fontColorThe color used for the font.
positionThe position of the object.
Returns:
The created object.
ProtectedPtr<TexturedArea> Group::CreateTexturedArea ( string  name,
Texture  image,
Vector2D  position,
Vector2D  areaSize 
)

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


Parameters:
nameThe name of the object.
imageThe texture rendered by the sprite.
positionThe position of the object.
areaSizeThe size of the rectangle in which the texture is displayed.
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.

ProtectedPtr<Group> Group::FindByNameGroup ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<ParticleSource> Group::FindByNameParticleSource ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<PhCircle> Group::FindByNamePhCircle ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<PhLine> Group::FindByNamePhLine ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<PhRect> Group::FindByNamePhRect ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<PhShape> Group::FindByNamePhShape ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<PhTriangle> Group::FindByNamePhTriangle ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<PostFX> Group::FindByNamePostFX ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<Screen> Group::FindByNameScreen ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<ScreenRenderer> Group::FindByNameScreenRenderer ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<Shape> Group::FindByNameShape ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<Sprite> Group::FindByNameSprite ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<Text> Group::FindByNameText ( string  name)

Find an object in the group with its name.

This function will also check the type of the object.

ProtectedPtr<TexturedArea> Group::FindByNameTexturedArea ( 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.

luaObject Group::GetDrawableChild ( number  index)

Return the drawable with the given index.

number Group::GetDrawableChildCount ( )

Return the number of drawable children that this group contains.

luaObject Group::GetPhysicChild ( number  index)

Return the physic child with the given index.

number Group::GetPhysicChildCount ( )

Return the number of physic children that this group contains.

luaObject Group::GetPreDestroyFunction ( )

Get the pre destroy function associated to this group.

See Group::SetPreDestroyFunction for more details.

Vector2D Group::GetScale ( )

Get the group scale.

bool Group::IsCut ( )

Return true if the cutting is enabled, false otherwise.

nil Group::SetCutRect ( Vector2D  position,
Vector2D  size 
)

Set the cut rectangle.

You should enable cutting.

nil Group::SetPreDestroyFunction ( luaObject  luaFunction)

Register an event to the group so that it will be destroyed when the group is destroyed.


This can be useful if some event can't work without an object and can create segmentation fault when they try to use a removed object.
This must be used with caution : if the event is already removed when the group is Destroyed, a segmentation fault will occure.
Do not regiser one event on more than one group ! Set the pre destroy function associated to this group.
When this group will be destroyed, its event function, if set, will be called right before the group is destroyed. It could be very usefull to destroy events related to this group when it's destroyed.
If nil is passed to this function, no function will be called on group destroy.
Arguments passed by the function : this group.

Parameters:
luaFunction: the function to be called
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