goo.object.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html>
  4. <head>
  5. <title>Module goo.object</title>
  6. <link rel="stylesheet" href="../luadoc.css" type="text/css" />
  7. <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
  8. </head>
  9. <body>
  10. <div id="container">
  11. <div id="product">
  12. <div id="product_logo"></div>
  13. <div id="product_name"><big><b></b></big></div>
  14. <div id="product_description"></div>
  15. </div> <!-- id="product" -->
  16. <div id="main">
  17. <div id="navigation">
  18. <h1>Goo</h1>
  19. <ul>
  20. <li><a href="../index.html">Index</a></li>
  21. </ul>
  22. <!-- Module list -->
  23. <h1>Modules</h1>
  24. <ul>
  25. <li>
  26. <a href="../modules/anim.html">anim</a>
  27. </li>
  28. <li>
  29. <a href="../modules/goo.html">goo</a>
  30. </li>
  31. <li>
  32. <a href="../modules/goo.button.html">goo.button</a>
  33. </li>
  34. <li>
  35. <a href="../modules/goo.checkbox.html">goo.checkbox</a>
  36. </li>
  37. <li>
  38. <a href="../modules/goo.colorpick.html">goo.colorpick</a>
  39. </li>
  40. <li>
  41. <a href="../modules/goo.image.html">goo.image</a>
  42. </li>
  43. <li>
  44. <a href="../modules/goo.null.html">goo.null</a>
  45. </li>
  46. <li><strong>goo.object</strong></li>
  47. <li>
  48. <a href="../modules/goo.panel.html">goo.panel</a>
  49. </li>
  50. <li>
  51. <a href="../modules/goo.progressbar.html">goo.progressbar</a>
  52. </li>
  53. <li>
  54. <a href="../modules/goo.text.html">goo.text</a>
  55. </li>
  56. <li>
  57. <a href="../modules/goo.textinput.html">goo.textinput</a>
  58. </li>
  59. </ul>
  60. <!-- File list -->
  61. </div><!-- id="navigation" -->
  62. <div id="content">
  63. <h1>Module <code>goo.object</code></h1>
  64. <p>This is the superclass for all goo objects, every object can access it's methods</p>
  65. <h2>Functions</h2>
  66. <table class="function_list">
  67. <tr>
  68. <td class="name" nowrap><a href="#goo.object:addToParent">goo.object:addToParent</a>&nbsp;(parent)</td>
  69. <td class="summary">This will hook the object onto the given parent </td>
  70. </tr>
  71. <tr>
  72. <td class="name" nowrap><a href="#goo.object:draw">goo.object:draw</a>&nbsp;()</td>
  73. <td class="summary">Internal </td>
  74. </tr>
  75. <tr>
  76. <td class="name" nowrap><a href="#goo.object:enterHover">goo.object:enterHover</a>&nbsp;()</td>
  77. <td class="summary">Callback function when the mouse enters the bounds of the object.</td>
  78. </tr>
  79. <tr>
  80. <td class="name" nowrap><a href="#goo.object:exitHover">goo.object:exitHover</a>&nbsp;()</td>
  81. <td class="summary">Callback function when the mouse exits the bounds of the object.</td>
  82. </tr>
  83. <tr>
  84. <td class="name" nowrap><a href="#goo.object:getAbsolutePos">goo.object:getAbsolutePos</a>&nbsp;(x, y)</td>
  85. <td class="summary">Gets the absolute position of the object.</td>
  86. </tr>
  87. <tr>
  88. <td class="name" nowrap><a href="#goo.object:getAbsoluteScale">goo.object:getAbsoluteScale</a>&nbsp;(x, y)</td>
  89. <td class="summary">Gets the absolute scale of the object.</td>
  90. </tr>
  91. <tr>
  92. <td class="name" nowrap><a href="#goo.object:getRelativePos">goo.object:getRelativePos</a>&nbsp;(x, y)</td>
  93. <td class="summary">Get the relative position of an object </td>
  94. </tr>
  95. <tr>
  96. <td class="name" nowrap><a href="#goo.object:getRelativeScale">goo.object:getRelativeScale</a>&nbsp;(xscale, yscale)</td>
  97. <td class="summary">Get the relative scale of an object </td>
  98. </tr>
  99. <tr>
  100. <td class="name" nowrap><a href="#goo.object:initialize">goo.object:initialize</a>&nbsp;(parent)</td>
  101. <td class="summary">Internal function called from goo.object:new() </td>
  102. </tr>
  103. <tr>
  104. <td class="name" nowrap><a href="#goo.object:isMouseHover">goo.object:isMouseHover</a>&nbsp;()</td>
  105. <td class="summary">is the mouse over the object? </td>
  106. </tr>
  107. <tr>
  108. <td class="name" nowrap><a href="#goo.object:mousePressed">goo.object:mousePressed</a>&nbsp;(x, y, button)</td>
  109. <td class="summary">Internal </td>
  110. </tr>
  111. <tr>
  112. <td class="name" nowrap><a href="#goo.object:mouseReleased">goo.object:mouseReleased</a>&nbsp;(x, y, button)</td>
  113. <td class="summary">Internal </td>
  114. </tr>
  115. <tr>
  116. <td class="name" nowrap><a href="#goo.object:onClick">goo.object:onClick</a>&nbsp;(x, y, button)</td>
  117. <td class="summary">Callback function when the object is clicked.</td>
  118. </tr>
  119. <tr>
  120. <td class="name" nowrap><a href="#goo.object:removeFromParent">goo.object:removeFromParent</a>&nbsp;()</td>
  121. <td class="summary">This will remove the object from it's parent, it will not remove it completely.</td>
  122. </tr>
  123. <tr>
  124. <td class="name" nowrap><a href="#goo.object:resetStyle">goo.object:resetStyle</a>&nbsp;()</td>
  125. <td class="summary">Resets the objects style to the one defined in style.lua </td>
  126. </tr>
  127. <tr>
  128. <td class="name" nowrap><a href="#goo.object:setColor">goo.object:setColor</a>&nbsp;(colorTable)</td>
  129. <td class="summary">Internal function used to set the drawing color, used instead of love.graphics.setColor.</td>
  130. </tr>
  131. <tr>
  132. <td class="name" nowrap><a href="#goo.object:setOpacity">goo.object:setOpacity</a>&nbsp;(opacity)</td>
  133. <td class="summary">Sets the opacity of the object </td>
  134. </tr>
  135. <tr>
  136. <td class="name" nowrap><a href="#goo.object:setPos">goo.object:setPos</a>&nbsp;(x, y)</td>
  137. <td class="summary">Sets the position of the object.</td>
  138. </tr>
  139. <tr>
  140. <td class="name" nowrap><a href="#goo.object:setScale">goo.object:setScale</a>&nbsp;(x, y)</td>
  141. <td class="summary">Sets the scale of the object.</td>
  142. </tr>
  143. <tr>
  144. <td class="name" nowrap><a href="#goo.object:setSize">goo.object:setSize</a>&nbsp;(w, h)</td>
  145. <td class="summary">Sets the size of the position and updates the bounds.</td>
  146. </tr>
  147. <tr>
  148. <td class="name" nowrap><a href="#goo.object:setStyle">goo.object:setStyle</a>&nbsp;(style)</td>
  149. <td class="summary">Sets the style of the object.</td>
  150. </tr>
  151. <tr>
  152. <td class="name" nowrap><a href="#goo.object:setVisible">goo.object:setVisible</a>&nbsp;(visible)</td>
  153. <td class="summary">Set whether the object should be drawn.</td>
  154. </tr>
  155. <tr>
  156. <td class="name" nowrap><a href="#goo.object:sizeToText">goo.object:sizeToText</a>&nbsp;()</td>
  157. <td class="summary"> </td>
  158. </tr>
  159. <tr>
  160. <td class="name" nowrap><a href="#goo.object:styleDidUpdate">goo.object:styleDidUpdate</a>&nbsp;()</td>
  161. <td class="summary">Called after goo.object:setStyle </td>
  162. </tr>
  163. <tr>
  164. <td class="name" nowrap><a href="#goo.object:update">goo.object:update</a>&nbsp;(dt)</td>
  165. <td class="summary">Internal </td>
  166. </tr>
  167. <tr>
  168. <td class="name" nowrap><a href="#goo.object:updateBounds">goo.object:updateBounds</a>&nbsp;()</td>
  169. <td class="summary">Updates the bounds of the object.</td>
  170. </tr>
  171. </table>
  172. <br/>
  173. <br/>
  174. <h2><a name="functions"></a>Functions</h2>
  175. <dl class="function">
  176. <dt><a name="goo.object:addToParent"></a><span>goo.object:</span><strong>addToParent</strong>&nbsp;( parent )</dt>
  177. <dd>
  178. <p class="func_description">This will hook the object onto the given parent</p>
  179. <h3>Parameters</h3>
  180. <ul>
  181. <li>
  182. <b>parent</b> <i><small>:goo_object</small></i><br/>the goo object to hook on to
  183. </li>
  184. </ul>
  185. <h3>See also:</h3>
  186. <ul>
  187. <li><a href="">
  188. goo.object:removeFromParent
  189. </a>
  190. </ul>
  191. </dd>
  192. <dt><a name="goo.object:draw"></a><span>goo.object:</span><strong>draw</strong>&nbsp;( )</dt>
  193. <dd>
  194. <p class="func_description">Internal</p>
  195. </dd>
  196. <dt><a name="goo.object:enterHover"></a><span>goo.object:</span><strong>enterHover</strong>&nbsp;( )</dt>
  197. <dd>
  198. <p class="func_description">Callback function when the mouse enters the bounds of the object.</p>
  199. </dd>
  200. <dt><a name="goo.object:exitHover"></a><span>goo.object:</span><strong>exitHover</strong>&nbsp;( )</dt>
  201. <dd>
  202. <p class="func_description">Callback function when the mouse exits the bounds of the object.</p>
  203. </dd>
  204. <dt><a name="goo.object:getAbsolutePos"></a><span>goo.object:</span><strong>getAbsolutePos</strong>&nbsp;( x, y )</dt>
  205. <dd>
  206. <p class="func_description">Gets the absolute position of the object. <br/>This function moves up through the entire instance hierarchy returning it's absolute position. <br/>If the parent object is at position 10,10 then obj:getRelativePos(5,5) returns 15,15</p>
  207. <h3>Parameters</h3>
  208. <ul>
  209. <li>
  210. <b>x</b> <i><small>:number</small></i><br/>the relative x position. (defaults to objects x position)
  211. </li>
  212. <li>
  213. <b>y</b> <i><small>:number</small></i><br/>the relative y position. (defaults to objects y position)
  214. </li>
  215. </ul>
  216. <h3>Return values:</h3>
  217. <ol>
  218. <li>number: absolute x position.
  219. <li>number: absolute y position.
  220. </ol>
  221. </dd>
  222. <dt><a name="goo.object:getAbsoluteScale"></a><span>goo.object:</span><strong>getAbsoluteScale</strong>&nbsp;( x, y )</dt>
  223. <dd>
  224. <p class="func_description">Gets the absolute scale of the object.</p>
  225. <h3>Parameters</h3>
  226. <ul>
  227. <li>
  228. <b>x</b> <i><small>:number</small></i><br/>the x scale (0-1) (defaults to objects x scale)
  229. </li>
  230. <li>
  231. <b>y</b> <i><small>:number</small></i><br/>the y scale (0-1) (defaults to objects y scale)
  232. </li>
  233. </ul>
  234. <h3>Return values:</h3>
  235. <ol>
  236. <li>number: the absolute x scale (0-1)
  237. <li>number: the absolute y scale (0-1)
  238. </ol>
  239. <h3>See also:</h3>
  240. <ul>
  241. <li><a href="">
  242. goo.object:getAbsolutePos
  243. </a>
  244. </ul>
  245. </dd>
  246. <dt><a name="goo.object:getRelativePos"></a><span>goo.object:</span><strong>getRelativePos</strong>&nbsp;( x, y )</dt>
  247. <dd>
  248. <p class="func_description">Get the relative position of an object</p>
  249. </dd>
  250. <dt><a name="goo.object:getRelativeScale"></a><span>goo.object:</span><strong>getRelativeScale</strong>&nbsp;( xscale, yscale )</dt>
  251. <dd>
  252. <p class="func_description">Get the relative scale of an object</p>
  253. </dd>
  254. <dt><a name="goo.object:initialize"></a><span>goo.object:</span><strong>initialize</strong>&nbsp;( parent )</dt>
  255. <dd>
  256. <p class="func_description">Internal function called from goo.object:new()</p>
  257. <h3>Parameters</h3>
  258. <ul>
  259. <li>
  260. <b>parent</b> <i><small>:goo_object</small></i><br/>the parent class to use.
  261. </li>
  262. </ul>
  263. <h3>See also:</h3>
  264. <ul>
  265. <li><a href="../modules/goo.html">
  266. goo
  267. </a>
  268. </ul>
  269. </dd>
  270. <dt><a name="goo.object:isMouseHover"></a><span>goo.object:</span><strong>isMouseHover</strong>&nbsp;( )</dt>
  271. <dd>
  272. <p class="func_description">is the mouse over the object?</p>
  273. <h3>Return value:</h3>
  274. <p class="func_return">bool: returns true if the mouse is over the object. false otherwise.</p>
  275. </dd>
  276. <dt><a name="goo.object:mousePressed"></a><span>goo.object:</span><strong>mousePressed</strong>&nbsp;( x, y, button )</dt>
  277. <dd>
  278. <p class="func_description">Internal</p>
  279. </dd>
  280. <dt><a name="goo.object:mouseReleased"></a><span>goo.object:</span><strong>mouseReleased</strong>&nbsp;( x, y, button )</dt>
  281. <dd>
  282. <p class="func_description">Internal</p>
  283. </dd>
  284. <dt><a name="goo.object:onClick"></a><span>goo.object:</span><strong>onClick</strong>&nbsp;( x, y, button )</dt>
  285. <dd>
  286. <p class="func_description">Callback function when the object is clicked. <br/>If this function exists it will be called when the mousePressed event occurs within the object's bounds.</p>
  287. <h3>Parameters</h3>
  288. <ul>
  289. <li>
  290. <b>x</b> <i><small>:number</small></i><br/>the absolute x position of the mouse.
  291. </li>
  292. <li>
  293. <b>y</b> <i><small>:number</small></i><br/>the absolute y position of the mouse.
  294. </li>
  295. <li>
  296. <b>button</b> <i><small>:string</small></i><br/>the button pressed. 'l' for left, 'r' for right, 'm' for middle.
  297. </li>
  298. </ul>
  299. <h3>Usage:</h3>
  300. <pre class='example'> local button = goo.button:new()<br /> button.name = 'bob'<br /> function button:onClick(x,y,button)<br /> if button == 'l' then<br /> print(self.name .. ' has been clicked')<br /> end<br /> end<br /> -- when the button is clicked with left mouse button it prints:<br /> -- bob has been clicked</pre><br />
  301. </dd>
  302. <dt><a name="goo.object:removeFromParent"></a><span>goo.object:</span><strong>removeFromParent</strong>&nbsp;( )</dt>
  303. <dd>
  304. <p class="func_description">This will remove the object from it's parent, it will not remove it completely. <br/>This can be used to unhook an object from it's parent preventing it from inheriting position. <br/>You could also bring an object to the top by calling removeFromParent followed by addToParent but <br/>there is a convient function <a href='#bringToTop'>bringToTop</a> for that.</p>
  305. <h3>See also:</h3>
  306. <ul>
  307. <li><a href="">
  308. goo.object:addToParent
  309. </a>
  310. <li><a href="">
  311. goo.object:bringToTop
  312. </a>
  313. </ul>
  314. </dd>
  315. <dt><a name="goo.object:resetStyle"></a><span>goo.object:</span><strong>resetStyle</strong>&nbsp;( )</dt>
  316. <dd>
  317. <p class="func_description">Resets the objects style to the one defined in style.lua</p>
  318. <h3>See also:</h3>
  319. <ul>
  320. <li><a href="">
  321. goo.object:setStyle
  322. </a>
  323. </ul>
  324. </dd>
  325. <dt><a name="goo.object:setColor"></a><span>goo.object:</span><strong>setColor</strong>&nbsp;( colorTable )</dt>
  326. <dd>
  327. <p class="func_description">Internal function used to set the drawing color, used instead of love.graphics.setColor. <br/>You should not need to use this unless you're overriding an objects draw method. <br/>It's much like love.graphics.setColor except it takes a table and respects the objects opacity methods.</p>
  328. <h3>Parameters</h3>
  329. <ul>
  330. <li>
  331. <b>colorTable</b> <i><small>:table</small></i><br/>a table of 3 or 4 color values {r,g,b,a} the values should have no keys. Alpha is optional.
  332. </li>
  333. </ul>
  334. </dd>
  335. <dt><a name="goo.object:setOpacity"></a><span>goo.object:</span><strong>setOpacity</strong>&nbsp;( opacity )</dt>
  336. <dd>
  337. <p class="func_description">Sets the opacity of the object</p>
  338. <h3>Parameters</h3>
  339. <ul>
  340. <li>
  341. <b>opacity</b> <i><small>:number</small></i><br/>the opacity value (0-255)
  342. </li>
  343. </ul>
  344. </dd>
  345. <dt><a name="goo.object:setPos"></a><span>goo.object:</span><strong>setPos</strong>&nbsp;( x, y )</dt>
  346. <dd>
  347. <p class="func_description">Sets the position of the object.</p>
  348. <h3>Parameters</h3>
  349. <ul>
  350. <li>
  351. <b>x</b> <i><small>:number</small></i><br/>x position
  352. </li>
  353. <li>
  354. <b>y</b> <i><small>:number</small></i><br/>y position
  355. </li>
  356. </ul>
  357. </dd>
  358. <dt><a name="goo.object:setScale"></a><span>goo.object:</span><strong>setScale</strong>&nbsp;( x, y )</dt>
  359. <dd>
  360. <p class="func_description">Sets the scale of the object.</p>
  361. <h3>Parameters</h3>
  362. <ul>
  363. <li>
  364. <b>x</b> <i><small>:number</small></i><br/>x scale (0-1)
  365. </li>
  366. <li>
  367. <b>y</b> <i><small>:number</small></i><br/>y scale (0-1)
  368. </li>
  369. </ul>
  370. </dd>
  371. <dt><a name="goo.object:setSize"></a><span>goo.object:</span><strong>setSize</strong>&nbsp;( w, h )</dt>
  372. <dd>
  373. <p class="func_description">Sets the size of the position and updates the bounds.</p>
  374. <h3>Parameters</h3>
  375. <ul>
  376. <li>
  377. <b>w</b> <i><small>:number</small></i><br/>width of the object
  378. </li>
  379. <li>
  380. <b>h</b> <i><small>:number</small></i><br/>height of the object
  381. </li>
  382. </ul>
  383. </dd>
  384. <dt><a name="goo.object:setStyle"></a><span>goo.object:</span><strong>setStyle</strong>&nbsp;( style )</dt>
  385. <dd>
  386. <p class="func_description">Sets the style of the object. <br/>each object has a style similar to CSS stylesheets. <br/>You can find these styles in goo/skins/{current skin}/style.lua <br/>This function's purpose is to override the styles defined in style.lua. <br/>To override pass a table with the same keys but you're overridden values.</p>
  387. <h3>Parameters</h3>
  388. <ul>
  389. <li>
  390. <b>style</b> <i><small>:table</small></i><br/>the <a href='goo.html#style'>style</a> which will override the style set in style.lua
  391. </li>
  392. </ul>
  393. <h3>See also:</h3>
  394. <ul>
  395. <li><a href="../modules/goo.html#style">
  396. goo.style
  397. </a>
  398. </ul>
  399. </dd>
  400. <dt><a name="goo.object:setVisible"></a><span>goo.object:</span><strong>setVisible</strong>&nbsp;( visible )</dt>
  401. <dd>
  402. <p class="func_description">Set whether the object should be drawn.</p>
  403. <h3>Parameters</h3>
  404. <ul>
  405. <li>
  406. <b>visible</b> <i><small>:bool</small></i><br/>Should the object be drawn?
  407. </li>
  408. </ul>
  409. </dd>
  410. <dt><a name="goo.object:sizeToText"></a><span>goo.object:</span><strong>sizeToText</strong>&nbsp;( )</dt>
  411. <dd>
  412. <p class="func_description"></p>
  413. </dd>
  414. <dt><a name="goo.object:styleDidUpdate"></a><span>goo.object:</span><strong>styleDidUpdate</strong>&nbsp;( )</dt>
  415. <dd>
  416. <p class="func_description">Called after goo.object:setStyle</p>
  417. <h3>See also:</h3>
  418. <ul>
  419. <li><a href="">
  420. goo.object:setStyle
  421. </a>
  422. </ul>
  423. </dd>
  424. <dt><a name="goo.object:update"></a><span>goo.object:</span><strong>update</strong>&nbsp;( dt )</dt>
  425. <dd>
  426. <p class="func_description">Internal</p>
  427. </dd>
  428. <dt><a name="goo.object:updateBounds"></a><span>goo.object:</span><strong>updateBounds</strong>&nbsp;( )</dt>
  429. <dd>
  430. <p class="func_description">Updates the bounds of the object. <br/>The bounds of the object are 4 points, representing the bounding box. <br/>This box is used to detect mouse events.</p>
  431. </dd>
  432. </dl>
  433. </div> <!-- id="content" -->
  434. </div> <!-- id="main" -->
  435. <div id="about">
  436. <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
  437. </div> <!-- id="about" -->
  438. </div> <!-- id="container" -->
  439. </body>
  440. </html>