Foros del Web » Creando para Internet » Flash y Actionscript »

Creando Un juego super simple

Estas en el tema de Creando Un juego super simple en el foro de Flash y Actionscript en Foros del Web. Hola, estoy creando un juego donde la bola no puede salirce del esenario, hasta hay voy. Entonses todo esta bien pero sompresa!, la bola se ...
  #1 (permalink)  
Antiguo 24/07/2011, 09:31
Avatar de nes24  
Fecha de Ingreso: julio-2005
Mensajes: 746
Antigüedad: 18 años, 9 meses
Puntos: 3
Creando Un juego super simple

Hola, estoy creando un juego donde la bola no puede salirce del esenario, hasta hay voy.

Entonses todo esta bien pero sompresa!, la bola se sale del senario:

Este es el codigo


// DENTRO DE LA BOLA


onClipEvent (load) {
velocidad=10;
destino=false;
}

onClipEvent (enterFrame) {
trace("-");
if( _root.ese.hitTest(_x+_width/2, _y, true) ){ // Subir
trace("N1");
while(_root.ese.hitTest(_x+_width/2, _y, true)){
if(destino=="derecha"){ _x-=15; }else{_y+=15;}
}
}else if(_root.ese.hitTest(_x, _y+_height/2, true)){ // Bajar
trace("N2");
while(_root.ese.hitTest(_x, _y+_height/2, true)){
if(destino=="izquierda"){ _x+=15;}else{_y-=15};
}
}else{
if( !(_root.ese.hitTest(_x+_width/2, _y, true)) ||
!(_root.ese.hitTest(_x, _y+_height/2, true))
){
if(Key.isDown(Key.UP)){ _y -= velocidad; destino="";}
if(Key.isDown(Key.DOWN)){ _y += velocidad; destino="";}
if(Key.isDown(Key.RIGHT)){ _x += velocidad; destino="derecha"; }
if(Key.isDown(Key.LEFT)){ _x -= velocidad; destino="izquierda"; }
}
}

}

Esturioso pero el efecto funciona bien, solo que en algunas partes se sale del ecenario no entiendo por que.




Aqui estan las fuentes:

http://hotelcaninoperroamor.com/Bola.rar

Agradesco la ayuda.
__________________
No hay nada que foros del web no sepa!!!!

Peca tanto quien presume de su belleza como de su inteligencia, ya que la brevedad de la vida aunque distorcionada siempre estara presente.
  #2 (permalink)  
Antiguo 24/07/2011, 21:09
Avatar de nes24  
Fecha de Ingreso: julio-2005
Mensajes: 746
Antigüedad: 18 años, 9 meses
Puntos: 3
Respuesta: Creando Un juego super simple

Bueno, como nadie me respondio pues yo me respondo solito:

Código HTML:
onClipEvent (load) {

}

onClipEvent (enterFrame) {
	trace("-");
	
		this.pointFront = {x:0, y:-_height/2};
		this.localToGlobal(this.pointFront);
		var fpx = this.pointFront.x;
		var fpy = this.pointFront.y;

		this.pointLeft = {x:-_width/2, y:0};
		this.localToGlobal(this.pointLeft);
		var lpx = this.pointLeft.x;
		var lpy = this.pointLeft.y;
		
		this.pointRight= {x:_width/2, y:0};
		this.localToGlobal(this.pointRight);
		var Rpx = this.pointRight.x;
		var Rpy = this.pointRight.y;
		
		this.pointBack= {x:0, y:_height/2};
		this.localToGlobal(this.pointBack);
		var Bpx = this.pointBack.x;
		var Bpy = this.pointBack.y;		
		

	if( _root.esenario.hitTest(fpx, fpy, true)   ){
		trace("pega Front");
		_y +=15;
	}

	if( _root.esenario.hitTest(lpx, lpy, true)   ){
		trace("pega Left");
		_x +=25;
	}
	
	if( _root.esenario.hitTest(Rpx, Rpy, true)   ){
		trace("pega Right");
		_x -=35;
	}	
	
	if( _root.esenario.hitTest(Bpx, Bpy, true)   ){
		trace("pega Back");
		_y -=30;
	}		
	
		if(Key.isDown(Key.UP)){	_y -= 5; }
		if(Key.isDown(Key.DOWN)){	_y +=5;}	
		if(Key.isDown(Key.LEFT)){	_x -=5;}	
		if(Key.isDown(Key.RIGHT)){	_x +=5;}	
	
}

Esto me funciono muy bien
__________________
No hay nada que foros del web no sepa!!!!

Peca tanto quien presume de su belleza como de su inteligencia, ya que la brevedad de la vida aunque distorcionada siempre estara presente.

Etiquetas: actionscript
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:40.