Mover Símbolo con Teclas y Colisiones
Descarga Recursos(Enlace actualizado)
https://drive.google.com/file/d/0B4wQ-bfpZOVVMHJKUm91MmVob00/view?usp=sharing&resourcekey=0-vsx17Eq2l9ft2MpnJ0zUlQ
Codigo:
import flash.events.*;
import flash.ui.Keyboard;
//posicion inicial del carro
icarro.x=stage.stageWidth/2;
icarro.y=380;
//variables para teclas cuando se preionar o se sueltan
var moverderecha:Boolean=false;
var moverizquierda:Boolean=false;
var moverarriba:Boolean=false;
var moverabajo:Boolean=false;
//variable de la velocidad al presionar las teclas
var velocidad:Number=5;
//crear las eventlistener con las funciones
stage.addEventListener(Event.ENTER_FRAME, mover);
stage.addEventListener(KeyboardEvent.KEY_DOWN, presionar);
stage.addEventListener(KeyboardEvent.KEY_UP, soltar);
//crear las funciones
function mover(event:Event):void{
//verificar colisiona el carro
if(icarro.hitTestObject(ihit1)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit2)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit3)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit4)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit5)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit6)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
//verificando las teclas para molvimiento
if(moverderecha==true){
icarro.x+=velocidad;
}
if(moverizquierda==true){
icarro.x-=velocidad;
}
if(moverabajo==true){
icarro.y+=velocidad;
}
if(moverarriba==true){
icarro.y-=velocidad;
}
}
function presionar(event:KeyboardEvent){
if(event.keyCode==39){
moverderecha=true;
}
if(event.keyCode==37){
moverizquierda=true;
}
if(event.keyCode==38){
moverarriba=true;
}
if(event.keyCode==40){
moverabajo=true;
}
}
function soltar(event:KeyboardEvent):void{
if(event.keyCode==39){
moverderecha=false;
}
if(event.keyCode==37){
moverizquierda=false;
}
if(event.keyCode==38){
moverarriba=false;
}
if(event.keyCode==40){
moverabajo=false;
}
}
Видео Mover Símbolo con Teclas y Colisiones канала rolandostudios
https://drive.google.com/file/d/0B4wQ-bfpZOVVMHJKUm91MmVob00/view?usp=sharing&resourcekey=0-vsx17Eq2l9ft2MpnJ0zUlQ
Codigo:
import flash.events.*;
import flash.ui.Keyboard;
//posicion inicial del carro
icarro.x=stage.stageWidth/2;
icarro.y=380;
//variables para teclas cuando se preionar o se sueltan
var moverderecha:Boolean=false;
var moverizquierda:Boolean=false;
var moverarriba:Boolean=false;
var moverabajo:Boolean=false;
//variable de la velocidad al presionar las teclas
var velocidad:Number=5;
//crear las eventlistener con las funciones
stage.addEventListener(Event.ENTER_FRAME, mover);
stage.addEventListener(KeyboardEvent.KEY_DOWN, presionar);
stage.addEventListener(KeyboardEvent.KEY_UP, soltar);
//crear las funciones
function mover(event:Event):void{
//verificar colisiona el carro
if(icarro.hitTestObject(ihit1)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit2)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit3)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit4)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit5)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
if(icarro.hitTestObject(ihit6)){
icarro.x=stage.stageWidth/2;
icarro.y=380;
}
//verificando las teclas para molvimiento
if(moverderecha==true){
icarro.x+=velocidad;
}
if(moverizquierda==true){
icarro.x-=velocidad;
}
if(moverabajo==true){
icarro.y+=velocidad;
}
if(moverarriba==true){
icarro.y-=velocidad;
}
}
function presionar(event:KeyboardEvent){
if(event.keyCode==39){
moverderecha=true;
}
if(event.keyCode==37){
moverizquierda=true;
}
if(event.keyCode==38){
moverarriba=true;
}
if(event.keyCode==40){
moverabajo=true;
}
}
function soltar(event:KeyboardEvent):void{
if(event.keyCode==39){
moverderecha=false;
}
if(event.keyCode==37){
moverizquierda=false;
}
if(event.keyCode==38){
moverarriba=false;
}
if(event.keyCode==40){
moverabajo=false;
}
}
Видео Mover Símbolo con Teclas y Colisiones канала rolandostudios
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Dibujos básicos con lineas en AutocadSalvemos la aldea con make code en minecraftEfecto viñeta en Adobe PremierDetras camaras la asistencia 2010Creando animación pajaritos volando en AnimateEfecto escribir a mano (Efecto Trazo: After Effect)Aplicar efecto dispersión en after effectsOpacidad en linea de tiempo en 3D MaxModelado Básico en BlenderComo exponer tus trabajos desde Roblox (Educación Lúdica)Insertando Medios en WordpressTexto 3D en PhotoshopFlashCS6 y VisualBasic2010Operaciones boolenas en AutoCADAPLICAR SOMBREADO CON CREADOR DE FORMASMascaras en flashEfecto demolición en 3DMaxTriangulo imposible en 3DStudio MaxEstructura condicional en python (2/3)Crear pagina responsive con pie de pagina siempre abajo.