I've made a project from Wolfie1996's Any direction scrolling project and I was wondering how I would make a solid object. I've tried quite a few different things but I can't work out how to do it. My object is a sprite.
Offline
recycle49 wrote:
I dont understand what you need.
Well, I've got my main character (a chicken) and he is looking round a house. I'm trying to put some furniture into the house but I don't want my chicken to walk through the furniture.
JeanTheFox wrote:
Maybe this post/topic can help?
The problem is, I still want the chicken to be able to move after he's crashed into the furniture.
Last edited by melikecheese (2010-11-07 13:43:38)
Offline
forever if: <touching furniture>
move -10 steps
_^
Offline
Hardmath123 wrote:
forever if: <touching furniture>
move -10 steps
_^
But I need him to stay in the center of the screen.
Last edited by melikecheese (2010-12-06 12:43:10)
Offline
Okay, so this might take a little explaining, but definitely can be done. Have you ever used sensor sprites? They look like this:
Notice that each side is a different color. That way, you can distinguish between left, right, up, and down. Now, you need your script. The sensor sprite has a ghost effect of 100, and it controls all movement. (The visible sprite, in this case a chicken, only moves to its position.)
Now you need to make it so the sprite won't move if it's pushing against an immovable object. Obviously, you can't restrict all movement if it's touching the terrain anywhere, because then you couldn't move away. So you need to restrict, for example, forward movement if the front of the sprite is touching an obstacle. In that case, the script would be:
When green flag clicked Forever If < <key up pressed > and not < <color (color on top) is touching color (color of obstacle)> > > change y by 5 EndIf EndForever
(Note here that the obstacle sprite is a solid color, and also has its ghost effect set to 100)
Then adapt that script for the other 3 directions. Make sense?
Offline
melikecheese wrote:
recycle49 wrote:
I dont understand what you need.
Well, I'e got my main character (a chicken) and he is looking round a house. I'm trying to put some furniture into the house but I don't want my chicken to walk through the furniture.
JeanTheFox wrote:
Maybe this post/topic can help?
The problem is, I still want the chicken to be able to move after he's crashed into the furniture.
Do you want the chicken to, say, be able to move left, right and down, but not up if it hit the furnishing on it's top?
EDIT: Never mind, Harakou explained it.
Last edited by ScratchReallyROCKS (2010-11-07 13:25:45)
Offline
Harakou wrote:
Okay, so this might take a little explaining, but definitely can be done. Have you ever used sensor sprites? They look like this:
http://i54.tinypic.com/hsrqtz.jpg
Notice that each side is a different color. That way, you can distinguish between left, right, up, and down. Now, you need your script. The sensor sprite has a ghost effect of 100, and it controls all movement. (The visible sprite, in this case a chicken, only moves to its position.)
Now you need to make it so the sprite won't move if it's pushing against an immovable object. Obviously, you can't restrict all movement if it's touching the terrain anywhere, because then you couldn't move away. So you need to restrict, for example, forward movement if the front of the sprite is touching an obstacle. In that case, the script would be:Code:
When green flag clicked Forever If < <key up pressed > and not < <color (color on top) is touching color (color of obstacle)> > > change y by 5 EndIf EndForever(Note here that the obstacle sprite is a solid color, and also has its ghost effect set to 100)
Then adapt that script for the other 3 directions. Make sense?
Thank you, but how would I put that into Wolfie1996's project? It's hard to explain, so maybe have a look at her project.
Offline
melikecheese wrote:
Harakou wrote:
Okay, so this might take a little explaining, but definitely can be done. Have you ever used sensor sprites? They look like this:
http://i54.tinypic.com/hsrqtz.jpg
Notice that each side is a different color. That way, you can distinguish between left, right, up, and down. Now, you need your script. The sensor sprite has a ghost effect of 100, and it controls all movement. (The visible sprite, in this case a chicken, only moves to its position.)
Now you need to make it so the sprite won't move if it's pushing against an immovable object. Obviously, you can't restrict all movement if it's touching the terrain anywhere, because then you couldn't move away. So you need to restrict, for example, forward movement if the front of the sprite is touching an obstacle. In that case, the script would be:Code:
When green flag clicked Forever If < <key up pressed > and not < <color (color on top) is touching color (color of obstacle)> > > change y by 5 EndIf EndForever(Note here that the obstacle sprite is a solid color, and also has its ghost effect set to 100)
Then adapt that script for the other 3 directions. Make sense?Thank you, but how would I put that into Wolfie1996's project? It's hard to explain, so maybe have a look at her project.
You should be able to just convert the "Change y" block to yscroll...
Oh, right. The object. If you make all the objects in a 360 by 480 region one sprite, then you should be able to just use the same script that is in the terrain background sprite for that same region.
Last edited by Harakou (2010-11-07 13:59:19)
Offline
Harakou wrote:
melikecheese wrote:
Harakou wrote:
Okay, so this might take a little explaining, but definitely can be done. Have you ever used sensor sprites? They look like this:
http://i54.tinypic.com/hsrqtz.jpg
Notice that each side is a different color. That way, you can distinguish between left, right, up, and down. Now, you need your script. The sensor sprite has a ghost effect of 100, and it controls all movement. (The visible sprite, in this case a chicken, only moves to its position.)
Now you need to make it so the sprite won't move if it's pushing against an immovable object. Obviously, you can't restrict all movement if it's touching the terrain anywhere, because then you couldn't move away. So you need to restrict, for example, forward movement if the front of the sprite is touching an obstacle. In that case, the script would be:Code:
When green flag clicked Forever If < <key up pressed > and not < <color (color on top) is touching color (color of obstacle)> > > change y by 5 EndIf EndForever(Note here that the obstacle sprite is a solid color, and also has its ghost effect set to 100)
Then adapt that script for the other 3 directions. Make sense?Thank you, but how would I put that into Wolfie1996's project? It's hard to explain, so maybe have a look at her project.
You should be able to just convert the "Change y" block to yscroll...
Oh, right. The object. If you make all the objects in a 360 by 480 region one sprite, then you should be able to just use the same script that is in the terrain background sprite for that same region.
THANK YOU!
Offline