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

#1 2012-09-04 12:50:33

gooeygoo
Scratcher
Registered: 2012-05-07
Posts: 82

Error in switching backgrounds

This is my 8-bit entry, but it needs fixing http://scratch.mit.edu/projects/gooeygoo/2762309
can sombody help me?


Play meh games, dont beh shy!!!
http://scratch.mit.edu/users/gooeygoo

Offline

 

#2 2012-09-04 14:11:24

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Error in switching backgrounds

Your "stage" sprite lacks a script for changing when the character touches the edge, a solution would be a variable, which you already have "x" and "y".

when gf clicked//stage sprite
forever
if <<(X) = (0)> and <(Y) = (0)>>
switch to costume [costume 1 v]
end
if <<(X) = (1)> and <(Y) = (0)>>
switch to costume [costume 2 v]
end

when gf clicked//for the character
forever
if <touching [edge v]?>
if <(x position) < (-230)>
change [X v] by (1)
set x to (230)
end
if <(x position) > (230)>
change [X v] by (-1)
set x to (-230)
end
and so forth for all edges, it's a limited script but it should work

Last edited by zammer990 (2012-09-04 14:11:51)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-09-04 23:58:42

gooeygoo
Scratcher
Registered: 2012-05-07
Posts: 82

Re: Error in switching backgrounds

And the Y?


Play meh games, dont beh shy!!!
http://scratch.mit.edu/users/gooeygoo

Offline

 

#4 2012-09-05 00:09:33

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Error in switching backgrounds

On the player




when gf clicked

set [y v] to [1]

set [real y v] to [1]

forever  

if <touching [up detect v]?> 

change [y v] by (1)

set y to (somewhere)

end

if <touching [down detect v]?> 

change [y v] by (-1)

set y to (somewhere)

end

if <(length of (y)) < [2]>

set [real y v] to (join [0] (y))

else

set [real y v] to (y)

end

set [etc v] to [etc]

end

The etc means something almost identical for x.

And on the stage put:


when gf clicked

forever  

switch to background (join (realx) (real y))

end

. This supports up to 99*99 backgrounds.


........................................................................................................................................................................................................................................

Offline

 

Board footer