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

#1 2013-01-26 23:51:27

itzCal
New Scratcher
Registered: 2013-01-19
Posts: 5

Making sprites scroll with a scrolling background.

hey Scratchers, I'm working on an update to my game, Anaba, which in the new version will use infinite scrolling techniques I've learned from the community. However, I have not found how to make certain sprites scroll along with the scrolling backgrounds. The main character always stays in the same position on the screen,  while obstacles are moving towards him as the background is scrolling as well. How do I accomplish this? Here's a few notes you should know:

Main sprite never moves

There is only infinite x-scrolling (background is moving from the right to the left)

>>>Obstacles start from the far right and travel in sync with the background to the left side.

THE ONLY THING I NEED HELP WITH IS THE LAST ONE!

Thanks guys, I appreciate any consideration, help, comment, etc.

Offline

 

#2 2013-01-27 05:57:15

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Making sprites scroll with a scrolling background.

Ok, so you have your scrollx variable, I hope.

For each obstacle or enemy give them a variable called startx.

Startx will be where on the map they are.

Inside the objects forever loop you put:

set x to <(scrollx) - (startx)>
This will cause obstacles to scroll with the background. For enemies you would manipulate the startx variable to change their positions.


http://i50.tinypic.com/ded8m.png

Offline

 

#3 2013-01-27 08:42:43

numberonegamers
Scratcher
Registered: 2012-07-12
Posts: 100+

Re: Making sprites scroll with a scrolling background.

When gf clicked
Forever
 Set x to ((xscroll) - [whatever you want])
End

When gf clicked
Forever
 If <<(x position) < [240]> and <(x position) > [-240]>>
  Show
 Else
  Hide
 End
End

Offline

 

#4 2013-01-27 21:11:43

itzCal
New Scratcher
Registered: 2013-01-19
Posts: 5

Re: Making sprites scroll with a scrolling background.

Ok thanks a lot, you both helped me out big time  smile

Offline

 

#5 2013-01-27 21:31:04

numberonegamers
Scratcher
Registered: 2012-07-12
Posts: 100+

Re: Making sprites scroll with a scrolling background.

itzCal wrote:

Ok thanks a lot, you both helped me out big time  smile

N problem!

Offline

 

Board footer