Aula menus
Click here to load reader
-
Upload
marcos-batista -
Category
Education
-
view
134 -
download
0
description
Transcript of Aula menus
Projeto de jogos RAD:GUI Texture e Menus
Augusto Bülow
Unity 3D• GUITexture: imagens 2D renderizadas
diretamente na tela• HUD: elementos de interface e display• Imagens: load, logos, cut-scenes, etc.• Botões / menus (2D)
Unity 3D• GUITexture:
• Importar imagem 2D (BMAP)• Criar GUITexture
• Propriedades básicas• posicionamento / escala• cor (adicional / tint)• PixelInSet (retangulo)
• Posicao e tamanho em pixels• Bordas: protege bordas de escala
Unity 3D• Setar BMAP para tamanho da tela:• Classe Screen
• Screen.width / Screen.height• Posição: Pivot = centro da imagemfunction Start () {
var size_x = Screen.width;
var size_y = Screen.height;
var pos_x = -size_x /2;
var pos_y = -size_y /2;
guiTexture.pixelInset = Rect (pos_x, pos_y, size_x, size_y);
}
Unity 3D• Criar efeito Tint / transparência no BMAP
• Componente de Cor (0..1) • color.a = alpha / transparência
var cor = 0.0;
function Update () {
if (cor < 0.5) { cor += 0.1 * Time.deltaTime; }
guiTexture.color.r = cor;
guiTexture.color.g = cor;
guiTexture.color.b = cor;
}
Unity 3D• Criar movimento nos bmaps
• pelo retângulo ( guiTexture.pixelInset )• pelo transform.position
...
if (cor < 0.5) {
transform.position.y += 0.1 * Time.deltaTime;
}
Unity 3D• Utilizando BMAPS como botões• Eventos do mouse (Functions / Messages)
• OnMouseDown
• OnMouseOver
• OnMouseExit
• OnMouseExit
• Criar / Inserir script com código especifico para as chamadas
Unity 3Dfunction OnMouseDown () {
Application.LoadLevel (1);
}
function OnMouseOver () {
guiTexture.color.r = 1;
guiTexture.color.g = 0.1;
guiTexture.color.b = 0.1;
}
function OnMouseExit () {
guiTexture.color.r = 0.5;
guiTexture.color.g = 0.5;
guiTexture.color.b = 0.5;
}
Unity 3D– Posição Z define ordem de renderização
–(qual mais a frente)
Unity 3D– Usar mesmo script para componentes do menu– Checar nome / definir ação
function OnMouseDown () {
if (gameObject.name == "botao1") {
Application.LoadLevel (1);
}if (gameObject.name == "botao2") {
Application.LoadLevel (2);}
}