Discuss Scratch

DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

I'm Currently working on Diep.io but before i add Scrolling, i must know how to make the Polygons go off screen and stay right where it should be…Please help me
amylaser
Scratcher
500+ posts

How to make Sprites go off screen and stay where it should be

Check out griffpatch's tutorials on scrolling:

scrolling in general: https://scratch.mit.edu/projects/93201751/
tile-based scrolling (good for platformers of this sort): https://scratch.mit.edu/projects/23134940/
DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

amylaser wrote:

Check out griffpatch's tutorials on scrolling:

scrolling in general: https://scratch.mit.edu/projects/93201751/
tile-based scrolling (good for platformers of this sort): https://scratch.mit.edu/projects/23134940/
Ok, i'll do that after i get back from school, lol theres school in Saturday, i have to go to bed now, btw i know griffpatch, he's the best Scratcher known
Pix3lAnimator
Scratcher
49 posts

How to make Sprites go off screen and stay where it should be

Check out tutorials on scrolling and that type of scripting I recommend @GriffPatch
DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

Pix3lAnimator wrote:

Check out tutorials on scrolling and that type of scripting I recommend @GriffPatch
Ok, i'm back from school, now to it's time to learn, in scratch…XD
DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

amylaser wrote:

Check out griffpatch's tutorials on scrolling:

scrolling in general: https://scratch.mit.edu/projects/93201751/
tile-based scrolling (good for platformers of this sort): https://scratch.mit.edu/projects/23134940/
Nope didn't help…
TheLogFather
Scratcher
1000+ posts

How to make Sprites go off screen and stay where it should be

Do you just mean that you want to know how to make a sprite slide ‘gracefully’ off the edge of the screen without getting ‘stuck’ at the edges?

If so, take a look at this demo project: https://scratch.mit.edu/projects/45908972/

Ignore the ‘wraparound’ aspect, and just concentrate on the comments inside that describe how the sprite can move off the edge of the screen without getting stuck.

DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

TheLogFather wrote:

Do you just mean that you want to know how to make a sprite slide ‘gracefully’ off the edge of the screen without getting ‘stuck’ at the edges?

If so, take a look at this demo project: https://scratch.mit.edu/projects/45908972/

Ignore the ‘wraparound’ aspect, and just concentrate on the comments inside that describe how the sprite can move off the edge of the screen without getting stuck.

Yes PS: i also know you, TheLogFather, Thanks! XD
DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

Actually, no, i want the Polygons to go off screen and stay where it should be, like Agar.io's Food, but Instead, Diep.io's Polygons (and Bullets)
To be Specific, I want the Polygons to go off screen and stay right where it spawned even you can't see it
Example: a Yellow Square going out of my View, and when i go back towards it, it's still where it Spawned
Do you Understand?
awesome-llama
Scratcher
1000+ posts

How to make Sprites go off screen and stay where it should be

You need to save the locations to variables. You can create 2 local variables, x and y. When the pentagon spawns, it needs the 2 variables to be set to it's position, and that is where it forever goes to.
TheLogFather
Scratcher
1000+ posts

How to make Sprites go off screen and stay where it should be

DraGoBoom wrote:

Actually, no, i want the Polygons to go off screen and stay where it should be, like Agar.io's Food, but Instead, Diep.io's Polygons (and Bullets)
To be Specific, I want the Polygons to go off screen and stay right where it spawned even you can't see it
Example: a Yellow Square going out of my View, and when i go back towards it, it's still where it Spawned
Do you Understand?
OK, yes – then see awesome-llama's reply above… You need to store an object's X,Y position in a couple of “this sprite only” variables (let's call them “My X” and “My Y”), and update those just as you would its X,Y position. However, when you place the object on the screen, you would just ‘offset’ these values by some ScrollX & ScrollY values:

gotox:MyX-ScrollXy:MyY-ScrollY
(Note that it's possible you may need to add ScrollX & ScrollY, instead of subtract, if you have written them to update the opposite way around to what I'm expecting for this. It'll work either way, as long as you do the updating of them consistently with the add or subtract.)


Since these objects end up moving off the edge of the screen, you will also need to use a method such as the one I linked above to prevent them from getting stuck at the edges…

Also, you probably want to hide the sprite when all of it has definitely gone right off the edge of the screen (and re-show it when part of it starts to come back on). – But also have a local variable which keeps its current state (i.e. visible or hidden), so that you are not continually running a “show” block all the time it is on-screen (instead, only doing one “show” when it first re-appears back on the screen).

Last edited by TheLogFather (Sept. 10, 2016 12:38:36)

DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

K, i kinda Understand what you mean, but i might have forgotten how to do Scrolling Stuff, so i'll go check some Tutorials and try to do what you said

Would you mind if i keep asking Questions? if so, i'm sorry, i don't mean to cause any Trouble
DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

I see what you mean, But wait, i don't want just One Polygon, i want lots, who wants to play it if there were only 3 Polygons Existing…lol
So what do i do? i don't wanna make Tons of Variables, Probably a List? but isn't that much harder…
TheLogFather
Scratcher
1000+ posts

How to make Sprites go off screen and stay where it should be

You don't make “tons of variables”. You only make a single pair of *local* variables (i.e. “this sprite only” variables).

Each clone (and the original sprite) has its own copy of such variables, and they change independently of each other.

Last edited by TheLogFather (Sept. 10, 2016 17:43:57)

DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

TheLogFather wrote:

You don't make “tons of variables”. You only make a single pair of *local* variables (i.e. “this sprite only” variables).

Each clone (and the original sprite) has its own copy of such variables, and they change independently of each other.

So you mean if i make 2 Variables (X/Y) for the Yellow Square Polygon, it applies to all of its clones?
DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

Omg it works!!! it stays where it spawned but 2 things…1. it spawns where i spawn and can't be moved (which makes a tight group of them) 2. it still shows on the Edge of the Screen
Did i put the Script at the Wrong place? or do i have to make a Separate one? idk
DraGoBoom
Scratcher
58 posts

How to make Sprites go off screen and stay where it should be

Nvm, i Figured it Out!

This Topic can now be Closed
awesome-llama
Scratcher
1000+ posts

How to make Sprites go off screen and stay where it should be

DraGoBoom wrote:

Nvm, i Figured it Out!

This Topic can now be Closed
There is a close topic button below, which you can click.

Powered by DjangoBB