Bottle 2D - Lua API 1.0.0
All you need to create games using bottle2D.
|
A Group is a container wich can contain drawable and physic object. More...
#include <header.hpp>
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< PhLine > | FindByNamePhLine (string name) |
Find an object in the group with its name. | |
ProtectedPtr< PhRect > | FindByNamePhRect (string name) |
Find an object in the group with its name. | |
ProtectedPtr< PhTriangle > | FindByNamePhTriangle (string name) |
Find an object in the group with its name. | |
ProtectedPtr< PhCircle > | FindByNamePhCircle (string name) |
Find an object in the group with its name. | |
ProtectedPtr< PhShape > | FindByNamePhShape (string name) |
Find an object in the group with its name. | |
ProtectedPtr< Group > | FindByNameGroup (string name) |
Find an object in the group with its name. | |
ProtectedPtr< ParticleSource > | FindByNameParticleSource (string name) |
Find an object in the group with its name. | |
ProtectedPtr< Shape > | FindByNameShape (string name) |
Find an object in the group with its name. | |
ProtectedPtr< Sprite > | FindByNameSprite (string name) |
Find an object in the group with its name. | |
ProtectedPtr< Text > | FindByNameText (string name) |
Find an object in the group with its name. | |
ProtectedPtr< PostFX > | FindByNamePostFX (string name) |
Find an object in the group with its name. | |
ProtectedPtr< Screen > | FindByNameScreen (string name) |
Find an object in the group with its name. | |
ProtectedPtr< ScreenRenderer > | FindByNameScreenRenderer (string name) |
Find an object in the group with its name. | |
ProtectedPtr< TexturedArea > | FindByNameTexturedArea (string name) |
Find an object in the group with its name. | |
ProtectedPtr< PhLine > | CreatePhLine (number phGroupId, string name, Vector2D pt1, Vector2D pt2) |
Create a new physic line and attach it to this group. | |
ProtectedPtr< PhRect > | CreatePhRect (number phGroupId, string name, Vector2D size) |
Create a new physic rectangle and attach it to this group. | |
ProtectedPtr< PhRect > | CreatePhRect (number phGroupId, string name, Vector2D position, Vector2D size) |
Create a new physic rectangle and attach it to this group. | |
ProtectedPtr< PhTriangle > | CreatePhTriangle (number phGroupId, string name, Vector2D pt1, Vector2D pt2, Vector2D pt3) |
Create a new physic triangle and attach it to this group. | |
ProtectedPtr< PhShape > | CreatePhShape (number phGroupId, string name) |
Create a physic shape and attach it to this group. | |
ProtectedPtr< PhCircle > | CreatePhCircle (number phGroupId, string name, Vector2D center, number radius) |
Create a new physic disk and attach it to this group. | |
ProtectedPtr< Group > | CreateGroup (string name) |
Create a Group object and add it to the current group. | |
ProtectedPtr< Group > | CreateGroup (string name, Vector2D position) |
Create a Group object and add it to the current group. | |
ProtectedPtr< ParticleSource > | CreateParticleSource (string name, ParticleModel model, number maxParticleNumber) |
Create a ParticleSource object and add it to the current group. | |
ProtectedPtr< Shape > | CreateShape (string name) |
Create a Shape object and add it to the current group. | |
ProtectedPtr< 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. | |
ProtectedPtr< 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. | |
ProtectedPtr< Shape > | 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. | |
ProtectedPtr< 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. | |
ProtectedPtr< Sprite > | CreateSprite (string name) |
Create a Sprite object and add it to the current group. | |
ProtectedPtr< Sprite > | CreateSprite (string name, Texture image, Vector2D position) |
Create a Sprite object and add it to the current group. | |
ProtectedPtr< Text > | CreateText (string name, string text) |
Create a Text object and add it to the current group. | |
ProtectedPtr< Text > | CreateText (string name, string text, number fontSize, Color fontColor, Vector2D position) |
Create a Text object and add it to the current group. | |
ProtectedPtr< PostFX > | CreatePostFX (string name) |
Create a PostFX object and add it to the current group. | |
ProtectedPtr< ScreenRenderer > | CreateScreenRenderer (string name) |
Create a ScreenRenderer object and add it to the current group. | |
ProtectedPtr< TexturedArea > | CreateTexturedArea (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. |
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.
ProtectedPtr<Group> Group::CreateGroup | ( | string | name | ) |
Create a Group object and add it to the current group.
name | The name of the object. |
Create a Group object and add it to the current group.
name | The name of the object. |
position | The position of the object. |
ProtectedPtr<ParticleSource> Group::CreateParticleSource | ( | string | name, |
ParticleModel | model, | ||
number | maxParticleNumber | ||
) |
Create a ParticleSource object and add it to the current group.
name | The name of the object. |
model | The particle model for this ParticleSource. |
maxParticleNumber | Used to reserve memory. It should not be oversized (unusefull memory would be allocated) or undersized (some particle won't be created)
|
ProtectedPtr<PhCircle> Group::CreatePhCircle | ( | number | phGroupId, |
string | name, | ||
Vector2D | center, | ||
number | radius | ||
) |
Create a new physic disk and attach it to this group.
phGroupId | The physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()). |
name | The name of the object. |
center | The center of the circle. Can be changed with Object::SetPosition(). |
radius | The radius of the disk. |
ProtectedPtr<PhLine> Group::CreatePhLine | ( | number | phGroupId, |
string | name, | ||
Vector2D | pt1, | ||
Vector2D | pt2 | ||
) |
Create a new physic line and attach it to this group.
phGroupId | The physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()). |
name | The name of the object. |
pt1 | First point of the line. |
pt2 | Second point of the line. |
ProtectedPtr<PhRect> Group::CreatePhRect | ( | number | phGroupId, |
string | name, | ||
Vector2D | position, | ||
Vector2D | size | ||
) |
Create a new physic rectangle and attach it to this group.
phGroupId | The physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()). |
name | The name of the object. |
position | The position of the rectangle. |
size | The size of the rectangle. |
Create a new physic rectangle and attach it to this group.
phGroupId | The physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()). |
name | The name of the object. |
size | The size of the rectangle. Use Object::SetPosition() to change the object's position. |
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 !
phGroupId | The physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()). |
name | The name of the 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.
phGroupId | The physic group of the object, in order to generate colision events (see Screen::AddPhysicGroup()). |
name | The name of the object. |
pt1 | First point of the triangle. |
pt2 | Second point of the triangle. |
pt3 | Third point of the triangle. |
ProtectedPtr<PostFX> Group::CreatePostFX | ( | string | name | ) |
Create a PostFX object and add it to the current group.
name | The name of the object. |
ProtectedPtr<ScreenRenderer> Group::CreateScreenRenderer | ( | string | name | ) |
Create a ScreenRenderer object and add it to the current group.
name | The name of the object. |
ProtectedPtr<Shape> Group::CreateShape | ( | string | name | ) |
Create a Shape object and add it to the current group.
name | The name of the 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.
name | The name of the object. |
P1 | Position of the first point |
P2 | Position second point |
Thickness | Line thickness |
Col | Color used to draw the line |
Outline | Outline width (0 by default) |
OutlineCol | Color used to draw the outline |
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.
name | The name of the object. |
position | Position of the first point |
size | The size of the rectangle |
Col | Color used to fill the rectangle |
Outline | Outline width |
OutlineCol | Color used to draw the outline |
ProtectedPtr<Sprite> Group::CreateSprite | ( | string | name | ) |
Create a Sprite object and add it to the current group.
name | The name of the object. |
ProtectedPtr<Text> Group::CreateText | ( | string | name, |
string | text | ||
) |
ProtectedPtr<TexturedArea> Group::CreateTexturedArea | ( | string | name, |
Texture | image, | ||
Vector2D | position, | ||
Vector2D | areaSize | ||
) |
Create a TexturedArea object and add it to the current group.
name | The name of the object. |
image | The texture rendered by the sprite. |
position | The position of the object. |
areaSize | The size of the rectangle in which the texture is displayed. |
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.
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.
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.
Edit scale.