Discuss Scratch

Jdeknoblo
New to Scratch
15 posts

i need help with having objects in certain stages be in certain stages

So say I have coins in one level (I have a leveling system where when you go to the side of the screen you change the level variable by one.) but i want the coins to not be there when you aren't on that level after they have basically cloned themselves in. so what i have is:
when green flag clicked
forever
if <(level) = [1]> then
go to x: (0) y: (0)
create clone of [myself v]
end
end

I also had the same thing with but with an if else and then delete this clone in an else. but that wont work as I expected. so i cant figure out how to make it delete when that stage is left. Thank you in advance
littlekitty5
Scratcher
18 posts

i need help with having objects in certain stages be in certain stages

when I start as a clone
wait until <(level) = ((level) + (1))>
delete this clone

Maybe try this? It's hard to tell what will work and what won't when you can't see the game, but when you're working with clones, you need to have “delete this clone” attached to the actual “when I start as a clone” block, otherwise I think errors occur. So add this script to your coin sprite and lemme know if it works!
Jdeknoblo
New to Scratch
15 posts

i need help with having objects in certain stages be in certain stages

I figured that to be true but it still doesn't seem to work I'll keep trying to figure it out but thanks for the help anyway. I don't really want to share my project just yet.
mstone326
Scratcher
1000+ posts

i need help with having objects in certain stages be in certain stages

Sharing the project is the best way to get accurate help. Or copy the project, take everything out that is not relevant to the question and share that.

If you think about your if level = 1 script, create clone. The clones are going to create 30 times per second until the level is not 1. At that point you'll have hit the clone limit of 301. And all the clones will be stacked on top of each other at x: 0, y: 0

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
Jdeknoblo
New to Scratch
15 posts

i need help with having objects in certain stages be in certain stages

@mstone326 Yeah I'm aware of that, when I wrote that script on the post I accidentally forgot to put the
stop [ this scriptv]
littlekitty5
Scratcher
18 posts

i need help with having objects in certain stages be in certain stages

Jdeknoblo wrote:

I figured that to be true but it still doesn't seem to work I'll keep trying to figure it out but thanks for the help anyway. I don't really want to share my project just yet.

If you're using an invisible sprite to detect when the player reaches the side of the screen and the sensor is hidden using a
hide
block it will not be able to interact with your other sprites and so will not change the value of your level variable. Make sure your sensor (*if it's invisible, or if you want it to be invisible*) is using a
set [ghost] effect to (100)
block instead of a hide block.

Make sure your coin sprite is ALSO using a “set ghost effect to 100” block. Otherwise it'll stay visible on the screen, so make sure that the coin sprite has scripts like these:

when green flag clicked
set [ghost] effect to (100)

when I start as a clone
set [ghost] effect to (0)
wait until <(level) = ((level) + (1))>
delete this clone

And that should work. : )

Last edited by littlekitty5 (May 18, 2018 03:23:12)

deck26
Scratcher
1000+ posts

i need help with having objects in certain stages be in certain stages

littlekitty5 wrote:

Jdeknoblo wrote:

I figured that to be true but it still doesn't seem to work I'll keep trying to figure it out but thanks for the help anyway. I don't really want to share my project just yet.

If you're using an invisible sprite to detect when the player reaches the side of the screen and the sensor is hidden using a
hide
block it will not be able to interact with your other sprites and so will not change the value of your level variable. Make sure your sensor (*if it's invisible, or if you want it to be invisible*) is using a
set [ghost] effect to (100)
block instead of a hide block.

Make sure your coin sprite is ALSO using a “set ghost effect to 100” block. Otherwise it'll stay visible on the screen, so make sure that the coin sprite has scripts like these:

when green flag clicked
set [ghost] effect to (100)

hide is often easier than using the ghost effect if you want nothing to interact with the sprite/clone.  Just hide the sprite and only show the clones.
when I start as a clone
set [ghost] effect to (0)
wait until <(level) = ((level) + (1))>
delete this clone

And that should work. : )
No it won't! A variable will NEVER be equal to itself plus 1.

If you want to do something like that you need to save the level in a variable and watch for the level changing relative to that variable.

set [oldlevel v] to (level)
wait until <(level) > (oldlevel)>

Last edited by deck26 (May 18, 2018 10:21:28)

Jdeknoblo
New to Scratch
15 posts

i need help with having objects in certain stages be in certain stages

deck26 wrote:

littlekitty5 wrote:

Jdeknoblo wrote:

I figured that to be true but it still doesn't seem to work I'll keep trying to figure it out but thanks for the help anyway. I don't really want to share my project just yet.

If you're using an invisible sprite to detect when the player reaches the side of the screen and the sensor is hidden using a
hide
block it will not be able to interact with your other sprites and so will not change the value of your level variable. Make sure your sensor (*if it's invisible, or if you want it to be invisible*) is using a
set [ghost] effect to (100)
block instead of a hide block.

Make sure your coin sprite is ALSO using a “set ghost effect to 100” block. Otherwise it'll stay visible on the screen, so make sure that the coin sprite has scripts like these:

when green flag clicked
set [ghost] effect to (100)

hide is often easier than using the ghost effect if you want nothing to interact with the sprite/clone.  Just hide the sprite and only show the clones.
when I start as a clone
set [ghost] effect to (0)
wait until <(level) = ((level) + (1))>
delete this clone

And that should work. : )
No it won't! A variable will NEVER be equal to itself plus 1.

If you want to do something like that you need to save the level in a variable and watch for the level changing relative to that variable.

set [oldlevel v] to (level)
wait until <(level) > (oldlevel)>

THIS IS EXACTLY WHAT I NEEDED thank you!
littlekitty5
Scratcher
18 posts

i need help with having objects in certain stages be in certain stages

deck26 wrote:

littlekitty5 wrote:

Jdeknoblo wrote:

I figured that to be true but it still doesn't seem to work I'll keep trying to figure it out but thanks for the help anyway. I don't really want to share my project just yet.

If you're using an invisible sprite to detect when the player reaches the side of the screen and the sensor is hidden using a
hide
block it will not be able to interact with your other sprites and so will not change the value of your level variable. Make sure your sensor (*if it's invisible, or if you want it to be invisible*) is using a
set [ghost] effect to (100)
block instead of a hide block.

Make sure your coin sprite is ALSO using a “set ghost effect to 100” block. Otherwise it'll stay visible on the screen, so make sure that the coin sprite has scripts like these:

when green flag clicked
set [ghost] effect to (100)

hide is often easier than using the ghost effect if you want nothing to interact with the sprite/clone.  Just hide the sprite and only show the clones.
when I start as a clone
set [ghost] effect to (0)
wait until <(level) = ((level) + (1))>
delete this clone

And that should work. : )
No it won't! A variable will NEVER be equal to itself plus 1.

If you want to do something like that you need to save the level in a variable and watch for the level changing relative to that variable.

set [oldlevel v] to (level)
wait until <(level) > (oldlevel)>

LMAO you're right X'D what was i thinking

Powered by DjangoBB