Estaba replicando algunos lasers de mis shoot em up favoritos , todo marchaba bien , hasta que intente replicar el laser beam tipo consolador del juego Dogyuun, el laser funciona adecuadamente, el unico problema fue que al colisionar el laser contra enemigos la punta del laser terminaba desapareciendo asi que decidi dibujar todo manual mente paso por paso osea con un monton de if, aqui les dejo el codigo del laser y el projecto por si quieren echarle un vistazo tal vez usted encuentre la solucion
laser animado projecto:
https://drive.google.com/file/d/1rB6IaLmGn__ApLcYIS_IzXErFB4AcQF5/view?usp=sharing
[gml]
//LASER STEP EVENT
///STANDARD LASER TEST
var laserTrim = keyboard_check_pressed(ord("W"));
frame += 0.3;
if(laserTrim){
laserEnd = 1;
laserLength = maxLength/choose(1,2,3);
}
//INIT LASER BEAM
if(image_xscale>0.1) && (!laserEnd)
{ x = pShip.x;
y = pShip.y;
depth += 0.05;
image_xscale -= 0.0125;
if(maxLength<512){maxLength +=32;}
for(i=0; i<maxLength; i++)
{ xEnd = x+lengthdir_x(i,90);
yEnd = y+lengthdir_y(i,90);
laserLength = i;
if(collision_point(xEnd,yEnd,parEn,0,0)) && (parEn.canStopLaser){
break;
}
}
}
//LASER END
if(image_xscale<=0.1) || (laserEnd){
speed = laserSpeed;
image_xscale -= 0.0025;
}
//ENEMIES TAKE DAMAGE
if(instance_exists(parEn))
{var hitting = ds_list_create();
hitting = collisionLineList(x,y,xEnd,yEnd,parEn,1,0);
if(hitting>0)
{for(var i=0; i<ds_list_size(hitting); i++;)
{var inst = ds_list_find_value(hitting,i);
if(inst.hitPoints!=0){
with(inst){
hitPoints--;
crashFX++;
}
}
}
ds_list_destroy(hitting);
}
}
//DESTROY LASER INSTANCE
if(image_xscale<=0){
instance_destroy();
}
if(y<=view_yview-sprite_height){
instance_destroy();
}
//DRAW EVENT
for(i=0; i<laserLength/32; i++){
draw_sprite(sprite5,frame,x,y-i*32); //cuerpo del laser
} draw_sprite(sprite4,frame,x,y-laserLength); //cabeza del lasaer
draw_sprite_ext(sprite4,frame,x,y,1,-1,0,c_white,1); //colita del laser
[/gml]
laser animado projecto:
https://drive.google.com/file/d/1rB6IaLmGn__ApLcYIS_IzXErFB4AcQF5/view?usp=sharing
[gml]
//LASER STEP EVENT
///STANDARD LASER TEST
var laserTrim = keyboard_check_pressed(ord("W"));
frame += 0.3;
if(laserTrim){
laserEnd = 1;
laserLength = maxLength/choose(1,2,3);
}
//INIT LASER BEAM
if(image_xscale>0.1) && (!laserEnd)
{ x = pShip.x;
y = pShip.y;
depth += 0.05;
image_xscale -= 0.0125;
if(maxLength<512){maxLength +=32;}
for(i=0; i<maxLength; i++)
{ xEnd = x+lengthdir_x(i,90);
yEnd = y+lengthdir_y(i,90);
laserLength = i;
if(collision_point(xEnd,yEnd,parEn,0,0)) && (parEn.canStopLaser){
break;
}
}
}
//LASER END
if(image_xscale<=0.1) || (laserEnd){
speed = laserSpeed;
image_xscale -= 0.0025;
}
//ENEMIES TAKE DAMAGE
if(instance_exists(parEn))
{var hitting = ds_list_create();
hitting = collisionLineList(x,y,xEnd,yEnd,parEn,1,0);
if(hitting>0)
{for(var i=0; i<ds_list_size(hitting); i++;)
{var inst = ds_list_find_value(hitting,i);
if(inst.hitPoints!=0){
with(inst){
hitPoints--;
crashFX++;
}
}
}
ds_list_destroy(hitting);
}
}
//DESTROY LASER INSTANCE
if(image_xscale<=0){
instance_destroy();
}
if(y<=view_yview-sprite_height){
instance_destroy();
}
//DRAW EVENT
for(i=0; i<laserLength/32; i++){
draw_sprite(sprite5,frame,x,y-i*32); //cuerpo del laser
} draw_sprite(sprite4,frame,x,y-laserLength); //cabeza del lasaer
draw_sprite_ext(sprite4,frame,x,y,1,-1,0,c_white,1); //colita del laser
[/gml]