Graphics Reference
In-Depth Information
username_input = object_list["UsernameText"]
password_input = object_list["PasswordText"]
cam = object_list["camera"]
mask = ""
Next, the case in which the mouse is moved over an object is considered, with the if mouse.positive
conditionalclause.Thisblockofcodewillbeexecutedanytimethemouseisoveranyobject.The hitObject
propertyiscalledontheMousesensortoretrievethespecificobjectthatthemouseisover.Thisobjectispassed
to the hit_object variable:
if mouse.positive:
hit_object = mouse.hitObject
The idea here is for the field that has the mouse over it to be active. This should be indicated by the appro-
priate white circle becoming visible, and it should result in the text input going to the appropriate variable. If
the username field has the mouse over it, the white circle on that field should be visible and any text the user
types should be interpreted as username input. Likewise, if the password field is active, typed text should be
interpreted as password input. There is one more thing that these clauses do; if the mouse has been moved from
another place, the input is cleared. This has the effect of clearing fields when the mouse has been moved away
andthenreturnedtothefield,whichmaynotbeidealbehavior.Thiscanbechanged,butforthesakeofkeeping
itsimpleforthisexample,Iwillacceptthisminoridiosyncrasy.Noteadifferencebetweenthecaseof field1 ,
the username field field2 , and the password field. In the first case, the cam.input value is passed to both
GL.name (the GameLogic property storing the username) and username_input.Text (the dynamic text
object representing the username text field). In the password case, the value is passed from cam.input to
GL.password but not directly to the dynamic text object. Rather, a variable called mask is introduced, and a
string of asterisks the same length as the password value is passed to this variable. This string is passed to the
dynamic text object, so the password is concealed.
if hit_object == field1:
if field1['active'] == 0:
cam['input'] = ""
circle1.setVisible(1)
circle2.setVisible(0)
field1['active'] = 1
field2['active'] = 0
username_input['Text'] = GL.name = cam['input']
elif hit_object == field2:
if field2['active'] == 0:
cam['input'] = ""
circle1.setVisible(0)
circle2.setVisible(1)
field1['active'] = 0
field2['active'] = 1
GL.password = cam['input']
for x in range(len(GL.password)):
mask = mask + "*"
password_input['Text'] = mask
Search WWH ::




Custom Search