|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
− | __TOC__
| + | #REDIRECT [[Message_in_a_Bottle]] |
− | ==About==
| |
− | This is a Message management library for LOVE. This library requires [[MiddleClass]].
| |
− | | |
− | [[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.
| |
− | | |
− | ==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.
| |
− | <source lang="lua">
| |
− | MessageBottle:new(id, text)
| |
− | </source>
| |
− | {{param|string|id|The unique identifier of the Bottle. e.g. "Open Door"}}
| |
− | {{param|string|text|The text to display on the Bottle. e.g. "Will you open the door?"}}
| |
− | | |
− | ===StayBottle===
| |
− | <source lang="lua">
| |
− | StayBottle:new(id, text)
| |
− | </source>
| |
− | {{param|string|id|The unique identifier of the Bottle. e.g. "Open Door"}}
| |
− | {{param|string|text|The text to display on the Bottle. e.g. "Will you open the door?"}}
| |
− | | |
− | ===TimeBottle===
| |
− | <source lang="lua">
| |
− | TimeBottle:new(id, text, timeout)
| |
− | </source>
| |
− | {{param|string|id|The unique identifier of the Bottle. e.g. "Open Door"}}
| |
− | {{param|string|text|The text to display on the Bottle. e.g. "Will you open the door?"}}
| |
− | {{param|number|timeout|The amount of time the bottle will display for.}}
| |
− | | |
− | ==Setter Functions==
| |
− | ===setX===
| |
− | <source lang="lua">
| |
− | MessageBottle:setX(x)
| |
− | </source>
| |
− | {{param|number|x|The x position of the Bottle}}
| |
− | | |
− | ===setY===
| |
− | <source lang="lua">
| |
− | MessageBottle:setY(y)
| |
− | </source>
| |
− | {{param|number|y|The y position of the Bottle}}
| |
− | | |
− | ===setPosition===
| |
− | <source lang="lua">
| |
− | MessageBottle:setPosition(x, y)
| |
− | </source>
| |
− | {{param|number|x|The x position of the Bottle}}
| |
− | {{param|number|y|The y position of the Bottle}}
| |
− | | |
− | ===setWidt===
| |
− | <source lang="lua">
| |
− | MessageBottle:setWidth(width)
| |
− | </source>
| |
− | {{param|number|width|The width of the Bottle}}
| |
− | | |
− | ===setHeight===
| |
− | <source lang="lua">
| |
− | MessageBottle:setHeight(height)
| |
− | </source>
| |
− | {{param|number|height|The height of the Bottle}}
| |
− | | |
− | ===setButton===
| |
− | <source lang="lua">
| |
− | MessageBottle:setButton(button)
| |
− | </source>
| |
− | {{param|KeyConstant|button|The button the Bottle will use.}}
| |
− | | |
− | ===setEase===
| |
− | <source lang="lua">
| |
− | MessageBottle:setEase(ease)
| |
− | </source>
| |
− | {{param|function|ease|The ease function to use for easing-in.}}
| |
− | | |
− | ===setEaseTime===
| |
− | <source lang="lua">
| |
− | MessageBottle:setEaseTime(easeTime)
| |
− | </source>
| |
− | {{param|number|easeTime|The time to spend easing-in.}}
| |
− | | |
− | ===setFade===
| |
− | <source lang="lua">
| |
− | MessageBottle:setFade(fade)
| |
− | </source>
| |
− | {{param|function|fade|The fade function to use for fading-in.}}
| |
− | | |
− | ===setFadeTime===
| |
− | <source lang="lua">
| |
− | MessageBottle:setFadeTime(fadeTime)
| |
− | </source>
| |
− | {{param|number|fadeTime|The time to spend fading-in.}}
| |
− | | |
− | ===setEnterCallback===
| |
− | <source lang="lua">
| |
− | MessageBottle:setEnterCallback(enterCB)
| |
− | </source>
| |
− | {{param|function|enterCB|The callback function to call on opening a bottle.}}
| |
− | | |
− | ===setExitCallback===
| |
− | <source lang="lua">
| |
− | MessageBottle:setEnterCallback(exitCB)
| |
− | </source>
| |
− | {{param|function|exitCB|The callback function to call on exiting a bottle.}}
| |
− | | |
− | ===setSound===
| |
− | <source lang="lua">
| |
− | MessageBottle:setSound(sound)
| |
− | </source>
| |
− | {{param|string|sound|The location of a sound file.}}
| |
− | | |
− | ===setVolume===
| |
− | <source lang="lua">
| |
− | MessageBottle:setVolume(volume)
| |
− | </source>
| |
− | {{param|number|volume|The volume of the sound. Normal volume is 1.0.}}
| |
− | | |
− | ===setIndicator===
| |
− | <source lang="lua">
| |
− | MessageBottle:setIndicator(indicator)
| |
− | </source>
| |
− | {{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">
| |
− | MessageBottle:setFgColor(r, g, b, a)
| |
− | </source>
| |
− | {{param|number|r|The red value from 0-255.}}
| |
− | {{param|number|g|The green value from 0-255.}}
| |
− | {{param|number|b|The blue value from 0-255.}}
| |
− | {{param|number|a|The alpha value from 0-255.}}
| |
− | | |
− | ===setFont===
| |
− | <source lang="lua">
| |
− | MessageBottle:setFont(font, size)
| |
− | </source>
| |
− | {{param|string|font|The location of the font file.}}
| |
− | {{param|number|size|The point value size.}}
| |
− | | |
− | ===setBgColor===
| |
− | <source lang="lua">
| |
− | MessageBottle:setFgColor(r, g, b, a)
| |
− | </source>
| |
− | {{param|number|r|The red value from 0-255.}}
| |
− | {{param|number|g|The green value from 0-255.}}
| |
− | {{param|number|b|The blue value from 0-255.}}
| |
− | {{param|number|a|The alpha value from 0-255.}}
| |
− | | |
− | ===setBgRadius===
| |
− | <source lang="lua">
| |
− | MessageBottle:setBgRadius(r)
| |
− | </source>
| |
− | {{param|number|r|The radius of the corners.}}
| |
− | | |
− | ===setBgRadiusSegments===
| |
− | <source lang="lua">
| |
− | MessageBottle:setBgRadiusSegments(n)
| |
− | </source>
| |
− | {{param|number|n|The number of segments to draw on each corner.}}
| |
− | | |
− | ==Example==
| |
− | <source lang="lua">
| |
− | 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
| |
− | </source>
| |
− | | |
− | == See Also ==
| |
− | * [[Libraries]]
| |
− | | |
− | {{#set:LOVE Version=0.7.0}}
| |
− | {{#set:Description=A message library for LOVE.}}
| |
− | [[Category:Libraries]] | |