Discuss Scratch

Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

This certain sprite will show and move every ten seconds then stop and repeat itself after another ten seconds. I've been trying to code this bit but when I try to use “wait 10 secs”, it just slows down my sprites movement. Here is my code:

whenIreceive Level Up hidegotofrontgotox:220y:pickrandom180to-100foreverwait10secsifxposition>-225thenshowmove10stepselsegotox:220y:pickrandom180to-100


Thank you
14152cool
Scratcher
100+ posts

Making sprite show after every ten seconds

Expelliarmus11 wrote:

This certain sprite will show and move every ten seconds then stop and repeat itself after another ten seconds. I've been trying to code this bit but when I try to use “wait 10 secs”, it just slows down my sprites movement.
I think this is what you want:
whenIreceivelevel up!hidegotofrontlayerforeverwait10secsifxposition>-255thenshowrepeatuntilxposition<-255move10stepsgotox:-220y:pickrandom180to-100elsegotox:-220y:pickrandom180to-100
Kraken_Games
Scratcher
100+ posts

Making sprite show after every ten seconds

Put the wait inside of the if, before the show.
And after the else, put a hide.


As a general rule, putting waits inside of forevers when they're not inside of ifs of elses will slow the entire script down, making the if only check once after it waits, then wait until the wait is done.
Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

Thank you so much!
Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

I have tried this code but it still doesn't work

14152cool wrote:

Expelliarmus11 wrote:

This certain sprite will show and move every ten seconds then stop and repeat itself after another ten seconds. I've been trying to code this bit but when I try to use “wait 10 secs”, it just slows down my sprites movement.
I think this is what you want:
whenIreceivelevel up!hidegotofrontlayerforeverwait10secsifxposition>-255thenshowrepeatuntilxposition<-255move10stepsgotox:-220y:pickrandom180to-100elsegotox:-220y:pickrandom180to-100
deck26
Scratcher
1000+ posts

Making sprite show after every ten seconds

You need to share the project so we can see why it didn't work.
Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

Kraken_Games wrote:

Put the wait inside of the if, before the show.
And after the else, put a hide.


As a general rule, putting waits inside of forevers when they're not inside of ifs of elses will slow the entire script down, making the if only check once after it waits, then wait until the wait is done.


I have tried this but it still doesn't work
Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

deck26 wrote:

You need to share the project so we can see why it didn't work.
https://scratch.mit.edu/projects/304212603/

Here it is. It's not finished yet so it may take a couple of retries to get it going. If you spot any problems with the coding or with anything that might need fixing, please let me know. Also, the part where the code is, is in the sprite called “Snitch”

Last edited by Expelliarmus11 (April 23, 2019 17:26:20)

deck26
Scratcher
1000+ posts

Making sprite show after every ten seconds

So when is it told to hide? Does it only do so once per level up?
Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

The snitch will appear on level 2 and will hide once level 3 starts(hasn't been coded yet). The main character will have to capture it to get to the next level. Therefore, it will appear every ten seconds to allow the player to have a chance to get it.
deck26
Scratcher
1000+ posts

Making sprite show after every ten seconds

Expelliarmus11 wrote:

The snitch will appear on level 2 and will hide once level 3 starts(hasn't been coded yet). The main character will have to capture it to get to the next level. Therefore, it will appear every ten seconds to allow the player to have a chance to get it.
But I don't see where you tell it to hide - it appears 10 seconds after the level up but you don't then tell it to hide do you?
Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

deck26 wrote:

Expelliarmus11 wrote:

The snitch will appear on level 2 and will hide once level 3 starts(hasn't been coded yet). The main character will have to capture it to get to the next level. Therefore, it will appear every ten seconds to allow the player to have a chance to get it.
But I don't see where you tell it to hide - it appears 10 seconds after the level up but you don't then tell it to hide do you?

Ah, sorry. I've been doing it on the offline version so I must've only done it on that version. My problem is just making the sprite show and move after every ten seconds without slowing its speed
deck26
Scratcher
1000+ posts

Making sprite show after every ten seconds

Expelliarmus11 wrote:

deck26 wrote:

Expelliarmus11 wrote:

The snitch will appear on level 2 and will hide once level 3 starts(hasn't been coded yet). The main character will have to capture it to get to the next level. Therefore, it will appear every ten seconds to allow the player to have a chance to get it.
But I don't see where you tell it to hide - it appears 10 seconds after the level up but you don't then tell it to hide do you?

Ah, sorry. I've been doing it on the offline version so I must've only done it on that version. My problem is just making the sprite show and move after every ten seconds without slowing its speed
I'm a bit confused - does the sprite appear in level 2 after 10 seconds and then move repeatedly until that level is complete and then hide? So the ‘every 10 seconds’ refers to the move but not the show?
Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

deck26 wrote:

Expelliarmus11 wrote:

deck26 wrote:

Expelliarmus11 wrote:

The snitch will appear on level 2 and will hide once level 3 starts(hasn't been coded yet). The main character will have to capture it to get to the next level. Therefore, it will appear every ten seconds to allow the player to have a chance to get it.
But I don't see where you tell it to hide - it appears 10 seconds after the level up but you don't then tell it to hide do you?

Ah, sorry. I've been doing it on the offline version so I must've only done it on that version. My problem is just making the sprite show and move after every ten seconds without slowing its speed
I'm a bit confused - does the sprite appear in level 2 after 10 seconds and then move repeatedly until that level is complete and then hide? So the ‘every 10 seconds’ refers to the move but not the show?

Basically, the sprite will appear after every ten seconds and scroll to the left in an attempt for the player to catch it. It will move like the sprites called “dementor” and “bludger”. If the player doesn't catch the sprite, then it will appear after another ten seconds. The sprite will then hide when it is the level after.
Kraken_Games
Scratcher
100+ posts

Making sprite show after every ten seconds

I'll remix with my alt to try to solve
Bludgeon_Games
Scratcher
5 posts

Making sprite show after every ten seconds

Expelliarmus11
Scratcher
15 posts

Making sprite show after every ten seconds

Bludgeon_Games wrote:

Complete: https://scratch.mit.edu/projects/304259154/

Thank you so much! You've fixed it and also made it better. By the way, do you know how to fix the start? When I press “click to start”, it sometimes go straight to the gameover screen?
Kraken_Games
Scratcher
100+ posts

Making sprite show after every ten seconds

Maybe some other time? I'm busy with a contest. . .
deck26
Scratcher
1000+ posts

Making sprite show after every ten seconds

Expelliarmus11 wrote:

Bludgeon_Games wrote:

Complete: https://scratch.mit.edu/projects/304259154/

Thank you so much! You've fixed it and also made it better. By the way, do you know how to fix the start? When I press “click to start”, it sometimes go straight to the gameover screen?
I've answered that in your other topic!

Powered by DjangoBB