I'm making a scrolling game but i'm stuck with making the enemies move. i have 5 terrain sprites and on the 2nd terrain sprite i want to put an enemy there. it keeps moving with the main character sprite but i want the enemy sprite to move independently.
Please help.
Offline
You'll need a variable called xpos for the enemy sprite only, and this script:
when gf clicked set [xpos v] to [0] forever if <([abs v] of (x position)) > [238]> hide else show end go to x: (((scrollx) + (480)) + (xpos)) y: (-50) //Y position is up to you. endTo make it move, change the xpos variable.
Offline
Gravitation wrote:
You'll need a variable called xpos for the enemy sprite only, and this script:
when gf clicked set [xpos v] to [0] forever if <([abs v] of (x position)) > [238]> hide else show end go to x: (((scrollx) + (480)) + (xpos)) y: (-50) //Y position is up to you.To make it move, change the xpos variable.
Fixed the forever stub.
Offline
thank you gravitation this really helped a lot! The enemy doesn't scroll with the main character anymore. But the enemy doesn't move. so would i just add normal moving scripts? and if so, where do i put the moving scripts?
Offline
Flammabl3 wrote:
thank you gravitation this really helped a lot! The enemy doesn't scroll with the main character anymore. But the enemy doesn't move. so would i just add normal moving scripts? and if so, where do i put the moving scripts?
As I said in my first post, you change the xpos variable to make the enemy move. For example:
when gf clicked set [xpos v] to [0] forever repeat (50) change [xpos v] by [1] end repeat (5) change [xpos v] by [-1] end end
Offline
Or you could just make that sprite have several costumes and make it look like it is moving! That is what I am going to do for my Mario game! ( it is still in progress ) but I have a moving platform that is just a bunch of costumes!
Offline