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

Screen Class Reference

A screen represent a part of your game where differenent physic and drawable object will evolve. More...

#include <header.hpp>

Inheritance diagram for Screen:
Group Drawable Object

List of all members.

Public Member Functions

ProtectedPtr< EventHandlerBaseRegisterButtonEvent (luaObject luaFunction, string keyName, bool pressed)
 Create a new button event.
ProtectedPtr< EventHandlerBaseRegisterButtonInZoneEvent (luaObject luaFunction, MouseZoneEvent zoneEvt, string keyName, bool pressed)
 Create a new button in zone event.
ProtectedPtr< EventHandlerBaseRegisterMouseMoveEvent (luaObject luaFunction)
 Create a new mouse move event.
ProtectedPtr< TimerRegisterTimer (luaObject luaFunction, number numbererval, bool isRunning=true)
 Create a new Timer.
ProtectedPtr< ChronometerRegisterChronometer (luaObject luaFunction, number totalTime, bool isRunning=true)
 Create a new chronometer.
ProtectedPtr< MouseZoneEventRegisterMouseZoneEvent (luaObject luaFunction, PhysicObject zone)
 Create a new mouse in zone event.
ProtectedPtr< EventHandlerBaseRegisterFrameEvent (luaObject luaFunction)
 Create a new Frame Event.
nil SetMouseRelative (bool relative)
 Turn on / off the mouse relative mode (cf: Screen::RegisterMouseMoveEvent)
bool IsMouseRelative ()
 Tels if the mouse is in a relative or absolute mode.
nil ShowCursor (bool show)
 Show / hide the mouse cursor.
bool IsCursorVisible ()
 Tels if the mouse cursor is shown.
number GetEventCount ()
 Get the number of event and pseudo event registered in this screen.
nil SetRenderScreen (luaObject renderScreen)
 Set the render screen and enable it.
luaObject GetRenderScreen ()
 Get the render screen or nil if no render screen where set.
nil SetTimeSpeed (number timeSpeed)
 Set time speed.
number GetTimeSpeed ()
 Get time speed.
nil AddPhysicGroup (number phGroupId1, number phGroupId2)
 Add a physic grpoup.
Color GetBackgroundColor ()
 Get the screen background color (also used for strip colors)
nil SetBackgroundColor (Color color)
 Set the screen background color (also used for strip colors)
ScreenConfig GetScreenConfig ()
 Get the screen configuration.
nil SetScreenConfig (ScreenConfig screenConfig)
 Set the screen configuration.
number GetUnusedPhGroup ()
 Return the first physic group that is not used by any PhysicObject in this Screen.
ProtectedPtr< SoundPlayerPlaySound (Sound sound)
 Play a the sound.
nil StopAllSounds ()
 Stop all the sound currently playing in this SoundManager.
bool IsCurrentRunningScreen ()
 Return true if this Screen is the current running screen, false otherwise.

Public Attributes

luabind::object renderScreen
 Access the render screen (See Screen::SetRenderScreen).
float timeSpeed
 Show the FPS (for optimisation)
Color backgroundColor
 Access the screen background color (also used for strip colors)
ScreenConfig screenConfig
 Access the screen configuration.

Detailed Description

A screen represent a part of your game where differenent physic and drawable object will evolve.

You can also attach event to your screen.
A bottle 2D app will always need a screen to run, but it is recomanded to use more than one. For example, you can create a menu screen and a game screen.
Then, when you can switch to the game / menu by calling ChangeScreen(). When a screen is not running, it is freezed : no sound, physic and events are proceeded.
Screens are created using the global function CreateScreen().


Member Function Documentation

nil Screen::AddPhysicGroup ( number  phGroupId1,
number  phGroupId2 
)

Add a physic grpoup.

To use physic intersecion events, you have to add some "physic group".
Each physic object has a group id which is attributed at creation. The engine will only test collisions between somme registered groups. So if you want to receive event when object of group 1 intersect object from group 3, you have to call AddPhysicGroup(1, 3) or AddPhysicGroup(3, 1).
Note: AddPhysicGroup(2, 2) is legal.

Color Screen::GetBackgroundColor ( )

Get the screen background color (also used for strip colors)

number Screen::GetEventCount ( )

Get the number of event and pseudo event registered in this screen.

luaObject Screen::GetRenderScreen ( )

Get the render screen or nil if no render screen where set.


See Screen::SetRenderScreen.

ScreenConfig Screen::GetScreenConfig ( )

Get the screen configuration.

number Screen::GetTimeSpeed ( )

Get time speed.

number Screen::GetUnusedPhGroup ( )

Return the first physic group that is not used by any PhysicObject in this Screen.

bool Screen::IsCurrentRunningScreen ( )

Return true if this Screen is the current running screen, false otherwise.

bool Screen::IsCursorVisible ( )

Tels if the mouse cursor is shown.

bool Screen::IsMouseRelative ( )

Tels if the mouse is in a relative or absolute mode.

ProtectedPtr<SoundPlayer> Screen::PlaySound ( Sound  sound)

Play a the sound.

A sound is linked to a screen. If you change screen, the sound will be paused and will resume when you select back the screen.

ProtectedPtr<EventHandlerBase> Screen::RegisterButtonEvent ( luaObject  luaFunction,
string  keyName,
bool  pressed 
)

Create a new button event.

The lua function luaFunction will be called each time the button keyName is pressed (if pressed = true) or released (if pressed = false).
Prototype of the called lua function : function luaFunction(keyName : string, pressedStatus : bool, thisEvent : EventHandlerBase).
Note: if keyName is empty (keyName = ""), then the lua function will be called each time a button is pressed / released.
Note2: The buttons could be mouse buttons, keyboard buttons and even joystick buttons.
See List of key names for the list of keys.

ProtectedPtr<EventHandlerBase> Screen::RegisterButtonInZoneEvent ( luaObject  luaFunction,
MouseZoneEvent  zoneEvt,
string  keyName,
bool  pressed 
)

Create a new button in zone event.

The lua function luaFunction will be called each time the button keyName is pressed (if pressed = true) or released (if pressed = false) and the mouse is in the zone corresponding to the zoneEvt.
Parameters of the called lua function : the key name (string), the pressed status (bool), the MouseZoneEvent which corresponds to the zone and the EventHandlerBase.
Note: if keyName is empty (keyName = ""), then the lua function will be called each time a button is pressed / released.
Note2: The buttons could be mouse buttons, keyboard buttons and even joystick buttons.
See List of key names for the list of keys.

ProtectedPtr<Chronometer> Screen::RegisterChronometer ( luaObject  luaFunction,
number  totalTime,
bool  isRunning = true 
)

Create a new chronometer.

The lua function luaFunction will be called at each frame during totalTime. It is very useful to create mouvement.
Parameters of the called lua function : the elapsed time ratio (float) and this Chronometer.
Note: The engine ensure that the function receive a ratio of 1 at the end of the chronometer.

ProtectedPtr<EventHandlerBase> Screen::RegisterFrameEvent ( luaObject  luaFunction)

Create a new Frame Event.

The lua function luaFunction will be called at each frame with the frame time (time between the last frame) and this eventHandler as a parameter

ProtectedPtr<EventHandlerBase> Screen::RegisterMouseMoveEvent ( luaObject  luaFunction)

Create a new mouse move event.

The lua function luaFunction will be called each time the mouse is moved.
Parameters of the called lua function : the mouse position (Vector2D) and this EventHandlerBase.
Note: if the mouse is configured as relative (cf: SetMouseRelative), then the position argument is the relative mouse mouvement.

ProtectedPtr<MouseZoneEvent> Screen::RegisterMouseZoneEvent ( luaObject  luaFunction,
PhysicObject  zone 
)

Create a new mouse in zone event.

The lua function luaFunction will be called each time the mouse enter or leave the PhysicObject zone.
Parameters of the called lua function : this MouseZoneEvent.
Note : Use MouseZoneEvent::IsInside() to see if the mouse is currently inside

ProtectedPtr<Timer> Screen::RegisterTimer ( luaObject  luaFunction,
number  numbererval,
bool  isRunning = true 
)

Create a new Timer.

The lua function luaFunction will be called at each interval while the timer is still running.
Parameters of the called lua function : this Timer.

nil Screen::SetBackgroundColor ( Color  color)

Set the screen background color (also used for strip colors)

nil Screen::SetMouseRelative ( bool  relative)

Turn on / off the mouse relative mode (cf: Screen::RegisterMouseMoveEvent)

nil Screen::SetRenderScreen ( luaObject  renderScreen)

Set the render screen and enable it.


A render screen is a normal Screen that is just meant to be rendered while this screen is the current active screen.
Usualy, a render screen contains multiple ScreenRenderer targeting this screen. It allows you to flip the screen.

Parameters:
renderScreenthe screen to be rendered or nil to render this screen
nil Screen::SetScreenConfig ( ScreenConfig  screenConfig)

Set the screen configuration.

nil Screen::SetTimeSpeed ( number  timeSpeed)

Set time speed.

nil Screen::ShowCursor ( bool  show)

Show / hide the mouse cursor.

nil Screen::StopAllSounds ( )

Stop all the sound currently playing in this SoundManager.


Member Data Documentation

Access the screen background color (also used for strip colors)

luabind::object Screen::renderScreen

Access the render screen (See Screen::SetRenderScreen).

Access the screen configuration.

Show the FPS (for optimisation)

Tels if FPS ate shown Access current time speed. Elapsed time = RealTime * timeSpeed


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