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

#1 2012-07-18 10:48:21

jono3814
New Scratcher
Registered: 2012-07-18
Posts: 17

making the backround move with the sprite.

hello, i just started using this program and dont know how to use it fully yet. I am making a project for school and need help. The assignment is to make an adventure game. For my project i would like the backround to move with the sprite as an endless loop creating a endless path for when you move the sprite. So when you move the sprite ( the sprite wont actually move, the backround will which i made a sprite too) please can someone help... this would be for the backround sprite...

[scratchblocks]
when [rightarrow] clicked
move (-5) steps
end

[scratchblocks]
when [leftarrow] clicked
move (5) steps
end

Offline

 

#2 2012-07-18 11:07:28

maxdoss
Scratcher
Registered: 2010-07-27
Posts: 1000+

Re: making the backround move with the sprite.

A way to do this would be scrolling, which you can look up on the wiki to get more help then we could give you.
http://wiki.scratch.mit.edu/wiki/Scratc … j673849j14

You can look through all those pages to find what you need!


It's my birthday. Deal with it.

Offline

 

#3 2012-07-18 11:13:21

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: making the backround move with the sprite.

You're thinking of scrolling. Read thissmile


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&display=small

Offline

 

#4 2012-07-18 11:18:15

thebriculator
Scratcher
Registered: 2011-07-11
Posts: 500+

Re: making the backround move with the sprite.

Here's what I think:

the easy way is to make a separate sprite for each page.

make this variable:

(scrollx)
In the stage or a separate sprite, make this script:

forever
if <[right arrow v] key pressed?>
change [scrollx v] by (-5)
end
if <[left arrow v] key pressed?>
change [scrollx v] by (5)
end
set [scrollx v] to ((scrollx) mod ((480) * (insert number of costumes here)))
end
the bottom line should make it loop.

then for each page, do this:

forever
set x to ((scrollx) + ((480) * (0)))//increment the zero for each page
if <(x position)=((scrollx) + ((480) * (0)))>//increment the zero here, too
show//this "if" statement makes it hide if it's too far off the stage.
else
hide
end
end
I hope this helps, and works, too!

Wow, major outpost. I should just go to the wiki next time.

Last edited by thebriculator (2012-07-18 11:26:53)


.     http://tiny.cc/2cwgpw    http://tiny.cc/viwgpw    http://tiny.cc/iwwgpw

Offline

 

#5 2012-07-18 12:21:33

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: making the backround move with the sprite.

thebriculator wrote:

forever
set x to ((scrollx) + ((480) * (0)))//increment the zero for each page
if <(x position)=((scrollx) + ((480) * (0)))>//increment the zero here, too
show//this "if" statement makes it hide if it's too far off the stage.
else
hide
end
end

Just to explain a bit if you're new to scratch, the reason we use 480 in the scripts is because the scratch stage is 480x360. So if you were scrolling on the Y axis you'd use 360 instead  smile


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

#6 2012-07-18 12:57:01

jono3814
New Scratcher
Registered: 2012-07-18
Posts: 17

Re: making the backround move with the sprite.

how would you set the backround to start at the first back round everytime you click the green flag ? so that the sprite starts at the first backround everytime you want to play...

Offline

 

#7 2012-07-18 12:59:14

wolfdude999
Scratcher
Registered: 2012-01-07
Posts: 1000+

Re: making the backround move with the sprite.

jono3814 wrote:

how would you set the backround to start at the first back round everytime you click the green flag ? so that the sprite starts at the first backround everytime you want to play...

Just have it set scrollx to 0

when gf clicked
set [scrollx v] to [0]

Last edited by wolfdude999 (2012-07-18 13:00:25)


http://i48.tinypic.com/15yxmp4.png

Offline

 

Board footer