Tutorial De Programacion En LUA - Capitulo 5

Todo sobre la primera portátil de Sony

Moderadores: Webmaster, Administrador, Moderador

Tutorial De Programacion En LUA - Capitulo 5

Notapor the_marioga » Viernes, 02 Abril 2010, 11:46

Capitulo 5. Menu Basico

Vamos ha aprender a hacer menus de seleccion. Y como esta a punto de empezar el internado(en efecto le e empezao un miercoles)

voy a empezar ya.

Lo explicare con un programilla

Código: Seleccionar todo
--Definimos colores
blanco = Color.new(255, 255, 255)
azul = Color. new(0, 0, 255)
--Variables
current = "espanol"
--Bucle
while true do
pad = Controls.read()
if pad:down() and current == "espanol" and pad~=prevpad then
current = "ingles"
prevpad=pad
end
if pad:down() and current == "ingles" and pad~=prevpad then
current = "espanol"
prevpad=pad
end
if pad:up() and current == "ingles" and pad~=prevpad then
current = "espanol"
prevpad=pad
end
if pad:up() and current == "espanol" and pad~=prevpad then
current = "ingles"
prevpad=pad
end
if pad:cross() and current == "espanol" and pad~=prevpad then
screen:print(140, 150, "Hola, este es el menu español", blanco)
screen.flip()
screen.waitVblankStart(100)      
end
if pad:cross() and current == "ingles" and pad~=prevpad then
screen:print(140, 150, "Hello, this is the english menu", blanco)
screen.flip()
screen.waitVblankStart(100)
end
prevpad=pad
screen:clear()
if current=="espanol" then
screen:print(1, 1, "Español", azul)
screen:print(1, 21, "Ingles", blanco)
elseif current=="ingles" then
screen:print(1, 1, "Español", blanco)
screen:print(1, 21, "Ingles", azul)
end
screen:print(1, 200, "Pulsa arriba y abajo para seleccionar la opcion deseada(azul)", blanco)
screen:print(1, 212, "Pulsa X para ejecutar la Opcion", blanco)
screen.waitVblankStart()
screen.flip()
end


Explicacion con X de mixta, XD

Código: Seleccionar todo
--Variables
current = "espanol"


Esa variable es la que nos va a ayudar a k funcione el menu, atentos a ella.

Código: Seleccionar todo
if pad:down() and current == "espanol" and pad~=prevpad then
current = "ingles"
prevpad=pad
end


Bien aqui dice, si pulsas abajo y la variable current es español y pad es difetente a prevpad entonces
current pasa a llamarse ingles y prevpad pasa a llamarse pad

Código: Seleccionar todo
if pad:cross() and current == "espanol" and pad~=prevpad then
screen:print(140, 150, "Hola, este es el menu español", blanco)
screen.flip()
screen.waitVblankStart(100)      
end


Y aqui nos dice si pulsas equis y la variable es español y prevpad es diferente a pad, muestra el texto de debajo

y asi se haria un menu
Avatar de Usuario
the_marioga
Colaborador
Colaborador
 
Mensajes: 21
Registrado: Miércoles, 17 Febrero 2010, 14:56

Volver a PlayStation Portable

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados

cron