OLPCities/Interface

From OLPC
Jump to: navigation, search

This library is part of the Gamelib, created by Scott Porter and updated by Brent Silby. Gamelib is available under the terms of the GNU Library General Public Licence.

To use this library (this Class) add one line to the <HEAD> section of the web page of the Lot.

You need to click this link and "save" the library at the same folder of the web page or put it at another folder at the same server and make a reference:

gamelib_interface.js

If you put it at the same folder, the line would be:

<script language="Javascript" src="gamelib_interface.js"></script> 

To create an "object" of the Class:

interface1=new In_Interface(200,200,'http://www.dmu.com/olpc'); 

The arguments are width, height and finally the path to the gamelib directory (the one containing all the gamelib_*.js files)


We do not use an object of this Class alone. We need to have, by example, an object of the Class Label added to it.

Methods


add(Object)              Adds an element to this interface. By example an object of the Class Label. 
 
hide()                  Hides the elements contained by the interface  

makeDraggable()          Makes the interface draggable. When dragged, all the elements 
                         the interface contains will move along with it.  

makeUndraggable()        Stops the interface from being draggable. 
 
moveTo(n,n)              Moves the interface to position x,y. This means all the elements contained 
                         by this interface will also be moved as an elements position is relative 
                         to the position of the interface that contains it.  

setBackground(URL of image) Sets a background image in the interface itself.  

setBgColor(Color)      Sets the background color of the interface itself. By default, interfaces 
                       are invisible.  

setZ(n)                Sets the Z index of the interface.   

show()                  Shows the elements contained by the interface  

Properties


bgColor                The current background color of the interface.   

visible                If true, the interface and its elements are visible.  

x                       The x position of the interface.    
y                       The y position of the interface.   
z                       The z position of the interface.