liamx's daddy writing:
http://scratch.mit.edu/projects/liamx/2746199
When the camera moves everything to the edge, the internal position between the sprites is changed. How do I avoid this?
The sprites will (in the full script) move independently, ie the rabbit will move around without having the door follow so the distance between them cannot be fixed.
BTW, (and this might be a "too big" question), why is there an outer limit to how far a sprite can go off edge? Why must they bump into a
Thank you all!
Offline
For some reason, as you've observed, sprites in Scratch can't move completely offscreen. This is probably to prevent people from "losing" sprites. However, it is a problem, especially when dealing with pen, since drawing off the side of the screen distorts the shape of the line.
It would probably be a better idea to use "set position" blocks instead of "change position" blocks. You can create a variable that holds the current scroll, or "camera" value, and a forever loop in both sprites that determines their positions based on that variable. The arrow buttons would then adjust the variable, rather than the sprites' position. For example:
This script goes in the right arrow sprite
when gf clicked set [scrollX v] to [0] forever if <touching [mouse pointer v]?> change [scrollX v] by [3] end end... and this one goes in the left arrow sprite
when gf clicked forever if <touching [mouse pointer v]?> change [scrollX v] by [-3] end endAnd then put one of these in each of the moving sprites. Replace "offset" with a value that represents how far the sprites should be offset from the "origin" at the beginning of the program. Judging from what you have already, I'd guess you'd want to use an offset of 0 for the rabbit and -179 for the door.
when gf clicked forever set x to ((scrollX) + [offset]) endHope that helps!
Last edited by amcerbu (2012-08-25 13:21:40)
Offline
Thank you both so much for your informative answers! Amcerbu, your solution works perfectly. I would never have figured this out!!!
Regarding the "can't get quite off the edge" issue, I'm starting a new thread.
Again, thank you!
Offline
No problem, I enjoy helping people with scripts! About the issue of the sprites not completely disappearing, you can create a "frame" sprite the size of the screen (480 x 360) with a black border around the edge, and with the interior of the sprite transparent (represented by the checkerboard pattern in the sprite editor). I'm not sure exactly how thick the border should be it will have to be to hide the sprites, but 30 pixels will surely do the trick. At the beginning of the program, this frame goes to the front of the screen. It will hide the spots on the edge where sprites are "sticking out."
Offline