Difference between revisions of "MessageInABottle"
(Defined all constructors and setter functions) |
|||
Line 1: | Line 1: | ||
− | + | __FORCETOC__ | |
− | + | =About= | |
This is a Message management library for LOVE. This library requires [[MiddleClass]]. | This is a Message management library for LOVE. This library requires [[MiddleClass]]. | ||
[[File:MessageInABottle.png]] | [[File:MessageInABottle.png]] | ||
− | + | =Contact= | |
No forum post yet. Go to the [http://bitbucket.org/dannyfritz/message-in-a-bottle/issues?status=new&status=open Issue Tracker] for bugs. Look around for [[User:Technocat |TechnoCat]] if you have any further questions or concerns. | No forum post yet. Go to the [http://bitbucket.org/dannyfritz/message-in-a-bottle/issues?status=new&status=open Issue Tracker] for bugs. Look around for [[User:Technocat |TechnoCat]] if you have any further questions or concerns. | ||
− | + | =Features= | |
* StayBottle, bottles that stay until a button is pressed. | * StayBottle, bottles that stay until a button is pressed. | ||
* TimedBottle, bottles that stay until a button is pressed or until a duration of time has passed. | * TimedBottle, bottles that stay until a button is pressed or until a duration of time has passed. | ||
Line 15: | Line 15: | ||
* Sleek and Stylish Bottle defaults | * Sleek and Stylish Bottle defaults | ||
− | + | ==Missing Features== | |
Not implemented yet, but plan to. | Not implemented yet, but plan to. | ||
* Boolean Bottles | * Boolean Bottles | ||
* Choice Bottles | * Choice Bottles | ||
− | + | =Configuring= | |
Much of the configuration you are going to want to do will take place at the top of MessageInABottle.lua. | Much of the configuration you are going to want to do will take place at the top of MessageInABottle.lua. | ||
− | + | =Constructors= | |
− | + | ==MessageBottle== | |
Do not use this. It is the parent class of all Bottles. | Do not use this. It is the parent class of all Bottles. | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 32: | Line 32: | ||
{{param|string|text|The text to display on the Bottle. e.g. "Will you open the door?"}} | {{param|string|text|The text to display on the Bottle. e.g. "Will you open the door?"}} | ||
− | + | ==StayBottle== | |
<source lang="lua"> | <source lang="lua"> | ||
StayBottle:new(id, text) | StayBottle:new(id, text) | ||
Line 39: | Line 39: | ||
{{param|string|text|The text to display on the Bottle. e.g. "Will you open the door?"}} | {{param|string|text|The text to display on the Bottle. e.g. "Will you open the door?"}} | ||
− | + | ==TimeBottle== | |
<source lang="lua"> | <source lang="lua"> | ||
TimeBottle:new(id, text, timeout) | TimeBottle:new(id, text, timeout) | ||
Line 47: | Line 47: | ||
{{param|number|timeout|The amount of time the bottle will display for.}} | {{param|number|timeout|The amount of time the bottle will display for.}} | ||
− | + | =Setter Functions= | |
− | + | ==setX== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setX(x) | MessageBottle:setX(x) | ||
Line 54: | Line 54: | ||
{{param|number|x|The x position of the Bottle}} | {{param|number|x|The x position of the Bottle}} | ||
− | + | ==setY== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setY(y) | MessageBottle:setY(y) | ||
Line 60: | Line 60: | ||
{{param|number|y|The y position of the Bottle}} | {{param|number|y|The y position of the Bottle}} | ||
− | + | ==setPosition== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setPosition(x, y) | MessageBottle:setPosition(x, y) | ||
Line 67: | Line 67: | ||
{{param|number|y|The y position of the Bottle}} | {{param|number|y|The y position of the Bottle}} | ||
− | + | ==setWidt== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setWidth(width) | MessageBottle:setWidth(width) | ||
Line 73: | Line 73: | ||
{{param|number|width|The width of the Bottle}} | {{param|number|width|The width of the Bottle}} | ||
− | + | ==setHeight== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setHeight(height) | MessageBottle:setHeight(height) | ||
Line 79: | Line 79: | ||
{{param|number|height|The height of the Bottle}} | {{param|number|height|The height of the Bottle}} | ||
− | + | ==setButton== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setButton(button) | MessageBottle:setButton(button) | ||
Line 85: | Line 85: | ||
{{param|KeyConstant|button|The button the Bottle will use.}} | {{param|KeyConstant|button|The button the Bottle will use.}} | ||
− | + | ==setEase== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setEase(ease) | MessageBottle:setEase(ease) | ||
Line 91: | Line 91: | ||
{{param|function|ease|The ease function to use for easing-in.}} | {{param|function|ease|The ease function to use for easing-in.}} | ||
− | + | ==setEaseTime== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setEaseTime(easeTime) | MessageBottle:setEaseTime(easeTime) | ||
Line 97: | Line 97: | ||
{{param|number|easeTime|The time to spend easing-in.}} | {{param|number|easeTime|The time to spend easing-in.}} | ||
− | + | ==setFade== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setFade(fade) | MessageBottle:setFade(fade) | ||
Line 103: | Line 103: | ||
{{param|function|fade|The fade function to use for fading-in.}} | {{param|function|fade|The fade function to use for fading-in.}} | ||
− | + | ==setFadeTime== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setFadeTime(fadeTime) | MessageBottle:setFadeTime(fadeTime) | ||
Line 109: | Line 109: | ||
{{param|number|fadeTime|The time to spend fading-in.}} | {{param|number|fadeTime|The time to spend fading-in.}} | ||
− | + | ==setEnterCallback== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setEnterCallback(enterCB) | MessageBottle:setEnterCallback(enterCB) | ||
Line 115: | Line 115: | ||
{{param|function|enterCB|The callback function to call on opening a bottle.}} | {{param|function|enterCB|The callback function to call on opening a bottle.}} | ||
− | + | ==setExitCallback== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setEnterCallback(exitCB) | MessageBottle:setEnterCallback(exitCB) | ||
Line 121: | Line 121: | ||
{{param|function|exitCB|The callback function to call on exiting a bottle.}} | {{param|function|exitCB|The callback function to call on exiting a bottle.}} | ||
− | + | ==setSound== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setSound(sound) | MessageBottle:setSound(sound) | ||
Line 127: | Line 127: | ||
{{param|string|sound|The location of a sound file.}} | {{param|string|sound|The location of a sound file.}} | ||
− | + | ==setVolume== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setVolume(volume) | MessageBottle:setVolume(volume) | ||
Line 133: | Line 133: | ||
{{param|number|volume|The volume of the sound. Normal volume is 1.0.}} | {{param|number|volume|The volume of the sound. Normal volume is 1.0.}} | ||
− | + | ==setIndicator== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setIndicator(indicator) | MessageBottle:setIndicator(indicator) | ||
Line 139: | Line 139: | ||
{{param|string|indicator|The location of the indicator image file. The indicator is the icon that bounces up and down on certain bottles.}} | {{param|string|indicator|The location of the indicator image file. The indicator is the icon that bounces up and down on certain bottles.}} | ||
− | + | ==setFgColor== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setFgColor(r, g, b, a) | MessageBottle:setFgColor(r, g, b, a) | ||
Line 148: | Line 148: | ||
{{param|number|a|The alpha value from 0-255.}} | {{param|number|a|The alpha value from 0-255.}} | ||
− | + | ==setFont== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setFont(font, size) | MessageBottle:setFont(font, size) | ||
Line 155: | Line 155: | ||
{{param|number|size|The point value size.}} | {{param|number|size|The point value size.}} | ||
− | + | ==setBgColor== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setFgColor(r, g, b, a) | MessageBottle:setFgColor(r, g, b, a) | ||
Line 164: | Line 164: | ||
{{param|number|a|The alpha value from 0-255.}} | {{param|number|a|The alpha value from 0-255.}} | ||
− | + | ==setBgRadius== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setBgRadius(r) | MessageBottle:setBgRadius(r) | ||
Line 170: | Line 170: | ||
{{param|number|r|The radius of the corners.}} | {{param|number|r|The radius of the corners.}} | ||
− | + | ==setBgRadiusSegments== | |
<source lang="lua"> | <source lang="lua"> | ||
MessageBottle:setBgRadiusSegments(n) | MessageBottle:setBgRadiusSegments(n) | ||
Line 176: | Line 176: | ||
{{param|number|n|The number of segments to draw on each corner.}} | {{param|number|n|The number of segments to draw on each corner.}} | ||
− | + | =Example= | |
<source lang="lua"> | <source lang="lua"> | ||
require 'MessageInABottle.lua' | require 'MessageInABottle.lua' | ||
Line 221: | Line 221: | ||
</source> | </source> | ||
− | + | = See Also = | |
* [[Libraries]] | * [[Libraries]] | ||
Revision as of 01:32, 19 November 2010
Contents
- 1 About
- 2 Contact
- 3 Features
- 4 Configuring
- 5 Constructors
- 6 Setter Functions
- 6.1 setX
- 6.2 setY
- 6.3 setPosition
- 6.4 setWidt
- 6.5 setHeight
- 6.6 setButton
- 6.7 setEase
- 6.8 setEaseTime
- 6.9 setFade
- 6.10 setFadeTime
- 6.11 setEnterCallback
- 6.12 setExitCallback
- 6.13 setSound
- 6.14 setVolume
- 6.15 setIndicator
- 6.16 setFgColor
- 6.17 setFont
- 6.18 setBgColor
- 6.19 setBgRadius
- 6.20 setBgRadiusSegments
- 7 Example
- 8 See Also
About
This is a Message management library for LOVE. This library requires MiddleClass.
Contact
No forum post yet. Go to the Issue Tracker for bugs. Look around for TechnoCat if you have any further questions or concerns.
Features
- StayBottle, bottles that stay until a button is pressed.
- TimedBottle, bottles that stay until a button is pressed or until a duration of time has passed.
- Ocean, a management object for Bottles
- Very (and hopefully easily) Configurable Bottles
- Sleek and Stylish Bottle defaults
Missing Features
Not implemented yet, but plan to.
- Boolean Bottles
- Choice Bottles
Configuring
Much of the configuration you are going to want to do will take place at the top of MessageInABottle.lua.
Constructors
MessageBottle
Do not use this. It is the parent class of all Bottles.
MessageBottle:new(id, text)
string id
- The unique identifier of the Bottle. e.g. "Open Door"
string text
- The text to display on the Bottle. e.g. "Will you open the door?"
StayBottle
StayBottle:new(id, text)
string id
- The unique identifier of the Bottle. e.g. "Open Door"
string text
- The text to display on the Bottle. e.g. "Will you open the door?"
TimeBottle
TimeBottle:new(id, text, timeout)
string id
- The unique identifier of the Bottle. e.g. "Open Door"
string text
- The text to display on the Bottle. e.g. "Will you open the door?"
number timeout
- The amount of time the bottle will display for.
Setter Functions
setX
MessageBottle:setX(x)
number x
- The x position of the Bottle
setY
MessageBottle:setY(y)
number y
- The y position of the Bottle
setPosition
MessageBottle:setPosition(x, y)
setWidt
MessageBottle:setWidth(width)
number width
- The width of the Bottle
setHeight
MessageBottle:setHeight(height)
number height
- The height of the Bottle
setButton
MessageBottle:setButton(button)
KeyConstant button
- The button the Bottle will use.
setEase
MessageBottle:setEase(ease)
function ease
- The ease function to use for easing-in.
setEaseTime
MessageBottle:setEaseTime(easeTime)
number easeTime
- The time to spend easing-in.
setFade
MessageBottle:setFade(fade)
function fade
- The fade function to use for fading-in.
setFadeTime
MessageBottle:setFadeTime(fadeTime)
number fadeTime
- The time to spend fading-in.
setEnterCallback
MessageBottle:setEnterCallback(enterCB)
function enterCB
- The callback function to call on opening a bottle.
setExitCallback
MessageBottle:setEnterCallback(exitCB)
function exitCB
- The callback function to call on exiting a bottle.
setSound
MessageBottle:setSound(sound)
string sound
- The location of a sound file.
setVolume
MessageBottle:setVolume(volume)
number volume
- The volume of the sound. Normal volume is 1.0.
setIndicator
MessageBottle:setIndicator(indicator)
string indicator
- The location of the indicator image file. The indicator is the icon that bounces up and down on certain bottles.
setFgColor
MessageBottle:setFgColor(r, g, b, a)
number r
- The red value from 0-255.
number g
- The green value from 0-255.
number b
- The blue value from 0-255.
number a
- The alpha value from 0-255.
setFont
MessageBottle:setFont(font, size)
setBgColor
MessageBottle:setFgColor(r, g, b, a)
number r
- The red value from 0-255.
number g
- The green value from 0-255.
number b
- The blue value from 0-255.
number a
- The alpha value from 0-255.
setBgRadius
MessageBottle:setBgRadius(r)
number r
- The radius of the corners.
setBgRadiusSegments
MessageBottle:setBgRadiusSegments(n)
number n
- The number of segments to draw on each corner.
Example
require 'MessageInABottle.lua'
function love.load()
love.graphics.setBackgroundColor(255,255,255)
--Initialize the ocean to manage the bottles.
--It is going to act as a Queue. FIFO
ocean = Ocean:new()
--Create a timed bottle and add it to the ocean
ocean:addBottle(TimeBottle:new(nil,"...",nil))
local bottle = StayBottle:new(nil,"What is this?")
bottle:setX(310)
bottle:setVolume(0)
ocean:addBottle(bottle)
end
function love.update(dt)
ocean:update(dt)
end
function love.draw()
background:draw()
love.graphics.setColor(0,0,0)
love.graphics.print(
'last bottle return was: '..ocean.response..
' at '..(math.floor(ocean.responseTime*10)/10)..
's from '..ocean.responseID,12,12)
ocean:draw()
end
function love.keypressed(k,u)
if k=="d" then
local x = math.floor(math.random(400))
local y = math.floor(math.random(150))
ocean:addBottle(TimeBottle:new("PRESSED_D","Timed Box!"))
elseif k=="escape" then
love.event.push("q")
end
end