This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-03 05:53:22

Flammabl3
New Scratcher
Registered: 2012-10-03
Posts: 2

Making enemies move in a scrolling game.

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

 

#2 2012-10-03 06:08:06

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: Making enemies move in a scrolling game.

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.
end
To make it move, change the xpos variable.  smile

Offline

 

#3 2012-10-03 06:21:16

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Making enemies move in a scrolling game.

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.  smile

Fixed the forever stub.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#4 2012-10-03 06:31:17

Flammabl3
New Scratcher
Registered: 2012-10-03
Posts: 2

Re: Making enemies move in a scrolling game.

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

 

#5 2012-10-08 17:55:41

tahutoa30
Scratcher
Registered: 2010-11-30
Posts: 4

Re: Making enemies move in a scrolling game.

maybe try "change xpos by 1" perhaps?


Max length.

Offline

 

#6 2012-10-09 01:44:30

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: Making enemies move in a scrolling game.

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

 

#7 2012-10-10 10:36:35

Friddle16
Scratcher
Registered: 2012-08-21
Posts: 100+

Re: Making enemies move in a scrolling game.

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!


http://oi46.tinypic.com/21c78yw.jpg

Offline

 

#8 2012-10-10 16:07:08

musclecf
Scratcher
Registered: 2012-09-07
Posts: 10

Re: Making enemies move in a scrolling game.

TA do

Offline

 

Board footer