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

#1 2012-06-06 18:56:21

FlipyKid
Scratcher
Registered: 2012-02-01
Posts: 3

Moving enemies whilst scrolling

Ive been working on a game where instead of "moving" your character is in a set position as he just scrolls (creates the affect of moving)

I have enemies also, but i cannot figure out a way to create a smooth move for them. I have them switching costumes but that creates jerky and not very pleasant motions.

Ive tried using X and Y coordinates but that wont work because the enemy wont stay where he is in the enviroment based on scrolling and its weird.

Also giving him his own scroll variables will not move him so any suggestions?

Offline

 

#2 2012-06-06 19:13:13

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Moving enemies whilst scrolling

Give him his own offset.  Let the scroll variable control him with his offset also controlling him.  It's hard to explain...would you like an example or is this enough information to help you?


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2012-06-06 19:43:25

FlipyKid
Scratcher
Registered: 2012-02-01
Posts: 3

Re: Moving enemies whilst scrolling

AtomicBawm3 wrote:

Give him his own offset.  Let the scroll variable control him with his offset also controlling him.  It's hard to explain...would you like an example or is this enough information to help you?

I'm not extremely great with terminology so ill need to know what offsetting is sorry if this is inconvenient to you. I'm newish.  ._.

Offline

 

#4 2012-06-06 20:41:02

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Moving enemies whilst scrolling

FlipyKid wrote:

AtomicBawm3 wrote:

Give him his own offset.  Let the scroll variable control him with his offset also controlling him.  It's hard to explain...would you like an example or is this enough information to help you?

I'm not extremely great with terminology so ill need to know what offsetting is sorry if this is inconvenient to you. I'm newish.  ._.

Ok, so basically you have a scrolling x value, correct?  This is the x position of the character but because of the way we're displaying the game, the x position of the character is 0.  This means the character's offset is the scrolling x value *-1.  If we were to change that to a constant, say 50, the character would eventually move off the screen because the offset is not keeping it on the screen like when we have it set to negative the scroll value.  For enemies, we can have the offset be between two numbers, say 100 and 200. We might use two scripts like this:

when gf clicked
forever
go to x:((scrollx)+(offset)) y:(0)
when gf clicked
set [offset v] to (100)
forever
repeat (100)
  change [offset v] by (1)
end
repeat (100)
  change [offset v] by (-1)
end
This is a very simple example and the two scripts could be combined, but this shows the basic idea.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#5 2012-06-06 20:54:06

FlipyKid
Scratcher
Registered: 2012-02-01
Posts: 3

Re: Moving enemies whilst scrolling

Thank you- now my hope isnt lost!

Offline

 

#6 2012-06-16 19:59:43

rocky862
Scratcher
Registered: 2010-07-30
Posts: 2

Re: Moving enemies whilst scrolling

When i use this to make an enemy move,i can always see the end of the enemy at the edge of my scren. why is this? how can i fix it?  hmm

Offline

 

#7 2012-06-17 00:46:17

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: Moving enemies whilst scrolling

because scratch doesn't allow sprites to move offscreen.


http://i47.tinypic.com/2iaa73k.png

Offline

 

#8 2012-06-17 11:08:48

rocky862
Scratcher
Registered: 2010-07-30
Posts: 2

Re: Moving enemies whilst scrolling

oh yeah. i found a way to fix it. you put black lines on each side of the screen

Offline

 

Board footer