Comunidad de diseño web y desarrollo en internet online

Ayuda con un scrip de movimiento...

Citar            
MensajeEscrito el 30 Jun 2006 01:35 am
Bue soy uno de esos q se keda abitualmente asta las 3 de la mañana (o mas) luchando con flash para crear algo lo mas aproximado a un juego..
basicamente aprendi algo de scrips con los samples q trae el MX...
estoy intentando crear un juego, pero necesito un poko q de ayuda con el movimiento de un mc, logre q mi mc se mueva con las flechas con el siguiente scrip

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= 7;
}
if (Key.isDown(Key.DOWN)) {
_y += 7;
}
if (Key.isDown(Key.LEFT)) {
_x -= 7;
}
if (Key.isDown(Key.RIGHT)) {
_x += 7;
}
if (Key.isDown(Key.SPACE)) {
this.play();
}
}

pero no me sirve mucho para lo q estoy haciendo... lo q realmente necesitaria es q q las flechas "LEFT" y "RIGHT" rote y q con "UP" avance segun la rotacion y que con "DOWN" retroceda.
Les agrecederia cualkier ayudita... dsd ya GraX.[/quote]

Por MiracleZ

3 de clabLevel



Genero:Masculino  

msie
Citar            
MensajeEscrito el 30 Jun 2006 04:57 am
ok man tu lo que quieres es que mc sea como un carro....jajajajaja....yo intente igual que tu hasta que lo logre.
yo tambien me quedo hasta tarde tratando de hacer juegos y este fue una incognita muy grande para mi.
asi que se lo que cuesta averiguar algo..pr eso te ayudare..para que me ayuden a mi que de verdad lo nesecito.

aqui te mando un script de un juego de carros...copialo i estudialo de pie a cabeza...para que sepas de que trata el asunto.

onClipEvent (load) {
var check1 = 0;
var check2 = 0;
var check3 = 0;
var totalLaps = 3;
var lapsMade = 0;
speed = 0;
}
onClipEvent (enterFrame) {
// make the car go forward
if (Key.isDown(Key.UP)) {
speed += 18;
}
// make the car go backwards
if (Key.isDown(Key.DOWN)) {
speed -= 5;
}
// tells the car to slow down after the speed of 20
if (Math.abs(speed)>35) {
speed *= .7;
}
// you can change the rotation of the car to your desire
if (Key.isDown(Key.LEFT)) {
_rotation -= 6;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 6;
}
// here is where the hittest is for the boundary
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.CPU1.hitTest(_x+x, _y+y, true)) {
} else {
speed *= -.6;
}
if (!_root.CPU2.hitTest(_x+x, _y+y, true)) {
} else {
speed *= -.6;
}
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_root.land._x -= x;
_root.map._x -= x;//changed
_root.CPU1._x -=x;
_root.CPU2._x -=x;
_root.checkpoints._x -=x;
_root.land._y -= y;
_root.map._y -= y;//changed
_root.CPU1._y -= y;
_root.CPU2._y -= y;
_root.checkpoints._y -=y;

} else {
speed *= -.6;
}

if (!_root.hitTest(checkPoint1_mc)) {
var check1 = 1;
}

if (!_root.hitTest(checkPoint2_mc)) {
var check2 = 1;
}

if (!_root.hitTest(checkPoint3_mc)) {
var check3 = 1;
}

if (!_root.hitTest(finishLine_mc)) {
if (check1 == 1 && check2 == 1 && check3 == 1){
lapsMade ++;
check1 = 0;
check2 = 0;
check3 = 0;
if (lapsMade == totalLaps){
_root.gotoAndStop(161);
}
}
}
}

Por jose manuel

3 de clabLevel



Genero:Masculino  

msie
Citar            
MensajeEscrito el 30 Jun 2006 10:40 pm
GraX.... me sirvio de mucho... solo q tiene unos errores q los aclaro por las dudas de q alguien mas los mire.

Parte del scrip defectuoso

x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;

Scrip corregido..

_x += Math.sin(_rotation*(Math.PI/180))*speed;
_y += Math.cos(_rotation*(Math.PI/180))*speed*-1;

Muchas gracias Jose Manuel... suerte con tus juegos flash ;)

Por MiracleZ

3 de clabLevel



Genero:Masculino  

msie

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.