if place_meeting(x+15,y+24,lightbeam) with (lightbeam) {instance_destroy()} instance_create (x+15,y+24,lightbeam)
y.speed= 50But it doesnt work. What i want it to do is if the object lightbeam is at the pouint 15,24 relative to mirror_up i want it to destroy the lightbeam and create a new light beam moving upwards with a speed of 50
code help
#1
Posted 19 August 2011 - 08:59 PM
#2
Posted 19 August 2011 - 09:42 PM
if place_meeting(x+15,y+24,lightbeam)
{
with (lightbeam) {instance_destroy()}
with (instance_create(x+15,y+24,lightbeam))
{
speed= 50
direction=90
}
}
Is this what you want?EDIT: Removed the space.
Edited by ATH Connect, 19 August 2011 - 09:58 PM.
#3
Posted 19 August 2011 - 09:44 PM
Edited by monkeyboy3217, 19 August 2011 - 09:46 PM.
#4
Posted 19 August 2011 - 09:44 PM
So i got this code
if place_meeting(x+15,y+24,lightbeam) with (lightbeam) {instance_destroy()} instance_create (x+15,y+24,lightbeam) y.speed= 50But it doesnt work. What i want it to do is if the object lightbeam is at the pouint 15,24 relative to mirror_up i want it to destroy the lightbeam and create a new light beam moving upwards with a speed of 50
if (place_meeting(x+15,y+24,lightbeam))
{ // <- important bracket
with (lightbeam) {instance_destroy();};
with (instance_create (x+15,y+24,lightbeam)) {v_speed= -50;}; // <- needs a with statement, imo
};
Try that... I can only guess that the problem is not bracketing the statements and functions after the if, and not using a 'with instance create'
which would set the speed of object 'y' to 50 continuously
---Edited some errors
Edited by C_Pike, 19 August 2011 - 09:48 PM.
#5
Posted 19 August 2011 - 09:47 PM
if x=mirror_up.x+15 and y=mirror_up.y+24
{
with (lightbeam) {instance_destroy()}
instance_create (x+15,y+24,lightbeam)
y.speed= 50
}It's off the top of my head...hope it works
#6
Posted 19 August 2011 - 09:50 PM
#7
Posted 19 August 2011 - 09:52 PM
Are you sure the object names do not conflict the names of the resources...try running the game in debug mode...None of these work and i have no idea why.....
#8
Posted 19 August 2011 - 09:54 PM
Maybe i have the collision coordinates wrong how would you check that?Are you sure the object names do not conflict the names of the resources...try running the game in debug mode...
None of these work and i have no idea why.....
#9
Posted 19 August 2011 - 09:55 PM
If it's an instance, then try naming it something else, like "inst_y" or "obj_y", then change it in the code to whatever you renamed it to.
#10
Posted 19 August 2011 - 09:58 PM
Y.speed is the current speed of the object on the y axisYou said "y.speed" as a variable... what is "y"?
If it's an instance, then try naming it something else, like "inst_y" or "obj_y", then change it in the code to whatever you renamed it to.
#11
Posted 19 August 2011 - 09:59 PM
Are you getting an error or just unintended results?
EDIT: Oh. Y? You named an object Y?
Edited by ATH Connect, 19 August 2011 - 10:00 PM.
#12
Posted 19 August 2011 - 10:03 PM
I did not name an object y but i am not getting an error code absolutely NOTHING happens :\Try my above code again. I removed the space in the instance_create function.
Are you getting an error or just unintended results?
EDIT: Oh. Y? You named an object Y?
EDIT: I tried your code again...same results...
Edited by monkeyboy3217, 19 August 2011 - 10:04 PM.
#13
Posted 19 August 2011 - 10:06 PM
So, here's what your code should be...
if (place_meeting(x+15,y+15,lightbeam)
{
with (lightbeam) instance_destroy();
obj = instance_create(x+15, y+24, lightbeam)
with (obj) vspeed = //whatever value you want here. read above for what value ^^
}That should work.
EDIT: Worked out all the mistakes. works now
Edited by wadaltmon, 19 August 2011 - 10:11 PM.
#14
Posted 19 August 2011 - 10:08 PM
Oh! Then that's not the code you want to use. Use the variable " hspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b]if (place_meeting(x+15,y+15,lightbeam)[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] {[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] with (lightbeam) instance_destroy();[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] obj = instance_create(x+15, y+24, lightbeam)[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] with (obj) vspeed = //whatever value you want here. read above for what value ^^[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] }[/b][/size][/color][/font] [b][font="monospace"][color="#000088"][size=2][b][/b]
That should work.
Umm code editor doesnt like it it says unexpected symbol line 1 position 1...i dont even think that GML code
EDIT: That or the website totally screwed up....
Edited by monkeyboy3217, 19 August 2011 - 10:09 PM.
#15
Posted 19 August 2011 - 10:12 PM
Oh! Then that's not the code you want to use. Use the variable " hspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b]if (place_meeting(x+15,y+15,lightbeam)[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] {[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] with (lightbeam) instance_destroy();[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] obj = instance_create(x+15, y+24, lightbeam)[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] with (obj) vspeed = //whatever value you want here. read above for what value ^^[/b][/size][/color][/font] [font="monospace"][color="#000088"][size=2][b] }[/b][/size][/color][/font] [b][font="monospace"][color="#000088"][size=2][b][/b]
That should work.
Umm code editor doesnt like it it says unexpected symbol line 1 position 1...i dont even think that GML code
EDIT: That or the website totally screwed up....
Website screwed up. Sorry. See my previous post for the real code.
#16
Posted 19 August 2011 - 10:14 PM
Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...if (place_meeting(x+15,y+15,lightbeam) { with (lightbeam) instance_destroy(); obj = instance_create(x+15, y+24, lightbeam) with (obj) vspeed = //whatever value you want here. read above for what value ^^ }
That should work.
EDIT: Worked out all the mistakes. works now
It doesnt like the frist french bracket...
#17
Posted 19 August 2011 - 10:17 PM
Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...if (place_meeting(x+15,y+15,lightbeam) { with (lightbeam) instance_destroy(); obj = instance_create(x+15, y+24, lightbeam) with (obj) vspeed = //whatever value you want here. read above for what value ^^ }
That should work.
EDIT: Worked out all the mistakes. works now
It doesnt like the frist french bracket...
What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.
#18
Posted 19 August 2011 - 10:18 PM
Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...if (place_meeting(x+15,y+15,lightbeam) { with (lightbeam) instance_destroy(); obj = instance_create(x+15, y+24, lightbeam) with (obj) vspeed = //whatever value you want here. read above for what value ^^ }
That should work.
EDIT: Worked out all the mistakes. works now
It doesnt like the frist french bracket...
What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.
Okay ill let you if it works
#19
Posted 19 August 2011 - 10:19 PM
if it says unknown variable obj, then before the third line, put in "var obj;"
Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...if (place_meeting(x+15,y+15,lightbeam) { with (lightbeam) instance_destroy(); obj = instance_create(x+15, y+24, lightbeam) with (obj) vspeed = //whatever value you want here. read above for what value ^^ }
That should work.
EDIT: Worked out all the mistakes. works now
It doesnt like the frist french bracket...
What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.
Okay ill let you if it works
#20
Posted 19 August 2011 - 10:20 PM
if it says unknown variable obj, then before the third line, put in "var obj;"
Oh! Then that's not the code you want to use. Use the variable " vspeed " for the movement on the y axis ( upward on the y axis is a negative number, downward is a positive number.
So, here's what your code should be...if (place_meeting(x+15,y+15,lightbeam) { with (lightbeam) instance_destroy(); obj = instance_create(x+15, y+24, lightbeam) with (obj) vspeed = //whatever value you want here. read above for what value ^^ }
That should work.
EDIT: Worked out all the mistakes. works now
It doesnt like the frist french bracket...
What? French bracket? (I assume you mean {}...)
Don't copy and paste. Just type in the code manually.
And where I put "//whatever value you want here. read above for what value ^^" I meant replace that with -50 or 50.
Okay ill let you if it works
ok
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











