How can I make objects, or in my case, walls, solid?
So when I drive my character into them, it doesn't go straight through?
I don't know if this has been asked before, but I cant find the answer.
Oh and I apologize if I don't reply instantly, Im eating
Offline
Jasmidge wrote:
How can I make objects, or in my case, walls, solid?
So when I drive my character into them, it doesn't go straight through?
I don't know if this has been asked before, but I cant find the answer.
Oh and I apologize if I don't reply instantly, Im eating
It's very nice too see that you are asking questions on the scratch forum. Please feel free to do so whenever you need help. Just if you have a question please post it on topic next time. For example, this post belongs in "All About Scratch" but this is understandable since this is your first time on the forums.
About your question:
Yes, in fact it is very possible to make objects solid. Let's say Sprite1 is the character that you are moving and Sprite2 is the wall.
Under Sprite1 you would put a script similar to this one:
[blocks]
<when green flag clicked>
<forever>
<if><touching[ sprite2
<stop all>
[/blocks]
This is of course if you are controlling your character with your mouse or arrow keys. You can also make the character bounce off the wall.
Ask anything whenever you need help.
Offline
As DistantVisit mentioned, this post would fit better in the All About Scratch forum - but don't worry! With just a few clicks of a mouse, myself or another moderator can move it over there for you I'll do that right now
Offline
Harakou wrote:
DistantVisit's solution is a good start, but of course, if you ever touch a wall, it will stop the entire project... here's an example of a way to fix that. Just add the other keys in with more If blocks.
Nice script, Harakou. My script was meant for a simple arrow control not a scrollx control. And, thanks for catching my mistake. I meant to put in a "stop script" block, but of course because of my status under the forums I can't edit that post. I will edit that as soon as I can.
Jasmidge wrote:
Thanks DistantVisit, Im going to try that now.
Make sure to put in a stop script block. Not a stop all. I made a little mistake
So put in this where the "stop all" belongs:
[blocks]
<stop script>
[/blocks]
I'm happy to help. ^^
Offline
If you are going to use distants script you will need to put those blocks in the movement script! And it will only work with very limited sorts of movement.
Harakous way is quite a bit better, but you will need to make 4 of those scripts for each direction and still will not work for all cases.
This question is quite vague as there are many different ways of movement with different ways of stopping them (E.G: Gliding, scroll X, Point and move steps, Change X) which all require different methods, and also what do you want to happen when it hits a wall? (E.G: Bounce back, stop game, start over, die)
Offline
Jasmidge wrote:
Thanks Wolfie1996. Sorry that I put it in the wrong forum.
No problem Everyone makes mistakes - and the "should I put this in New Members or All About Scratch?" problem is one that catches a lot of people out ^^
Offline
Make 2 variables, temporary x and temporary y. Make a script setting temporary x and y to x position and y position. Then, after the movement part, put if touching (whatever), set x to temporary x, y to temporary y. (works for top down/birds eye view. You'd need to change y by 1 or something for platformers because you touch land in platformers).
Offline
Once you get a project started, upload it. Then come back here and make a link to it and describe what you want it to do and the various AAS forum squad will be on it like ants on candy.
ps.. do this for ANY troubling scripting problem you have in the future. And of course you are welcome to jump in and help others if you see a post you feel like you can help with. But you have to be quick to be first, lol!
Offline
Locomule wrote:
And of course you are welcome to jump in and help others if you see a post you feel like you can help with. But you have to be quick to be first, lol!
Yup. Coolstuff always gets me with his ninja posts...
On-topic: You might notice that you can get "stuck" on a wall. If that happens, try using color sensing on each side of your sprite. (Make sure each color is specific to one side) Then use "If color _ is touching color _" instead of "If touching _" Make sure you have a different color sensing block for each side. For example, if you had red on the right side, do this:
If <<Key right arrow pressed> and <not(color red is touching color [color of walls])> Change x by 10
I'm not sure if I explained that well; if I didn't, then tell me and I'll try to explain better. (Or someone else can help of course.)
If you didn't notice the problem I was talking about, disregard this post.
Last edited by Harakou (2010-07-31 22:51:56)
Offline
coolstuff=modbot... he never rests
but Harakou, you ain't so shabby either my friend! Kudos to your dedication as well
Me, I've just had wayyyy to much spare time that will run out soon enough anyway when I get a new job. Too bad you can't get paid to work for Scratch from home. They would get more than their money's worth from myself and a lot of people around here!!
Offline
sorry to inturrupt but i want my characters to die and restart, HOW?
Offline