Discuss Scratch

Puwexil
Scratcher
100+ posts

How to make an object go to another sprite's position and adjusting with size.

Like, if i put something like
set y to (([yposition v] of [Sprite1 v]) - (50))
Assuming these two different objects are the same size, when you make the sprite bigger, they're gonna look closer to each other, and more apart when making it smaller.
How do I make to adjust to the size of the sprite?
python_megapixel
Scratcher
500+ posts

How to make an object go to another sprite's position and adjusting with size.

If you have two sprites called sprite1 and sprite2, create a variable visible to all sprites called something like s1size. Then add a script to sprite1 to permanently set the variable to its size:
when green flag clicked
forever
set [s1size v] to (size)
end

Then add to your moving script in sprite2
set y to (([yposition v] of [Sprite1 v]) - (50))
set size to (s1size)

Then, if you change the size of sprite1, sprite2 will change as well.

Last edited by python_megapixel (Jan. 2, 2018 09:27:01)

Puwexil
Scratcher
100+ posts

How to make an object go to another sprite's position and adjusting with size.

I don't think you understand as what you explained was really basic, but anyways, since you understood both sprites have to change the same size, but seemed to ignore the “set y to x”, here's what I mean
Make an sprite go to another, like set x to x position of sprite 1, and set y to y position of sprite 1-50, ok?
Now, If I zoomed BOTH sprites, you'll see both sprites become bigger, and also look closer to each other, since the y position, doesn't change accordingly to the size, get it?

Last edited by Puwexil (Jan. 2, 2018 14:47:37)

Silencer59
Scratcher
27 posts

How to make an object go to another sprite's position and adjusting with size.

That could work, you would need an additional Variable: S2Base which you would set to what you wish you second sprites size to be by default. but if you want them to remain the same difference in size rather than the SAME size then
you should make it so that When green flag clicked, Forever, size = S1Size + S2Base.

if your sprite1 is Size 160 and you want your sprites to be 100 apart, Sprite 2 would be 260 because S1Size(160) + S2Base(100) = 260.


Puwexil
Scratcher
100+ posts

How to make an object go to another sprite's position and adjusting with size.

Again it's seems people are misunderstanding, size matching another sprite is not the problem at all.
The problem is the sprite's position, being 50 steps apart like I said, when you zoom both sprites they look closer to eache other, I want to keep the same position difference in all sizes, just try what I said, with a sprite with a size of 100, then zoom it.
The title may have been a bit misleading, but I mean adjusting the positions according to size.

Last edited by Puwexil (Jan. 2, 2018 15:52:46)

Silencer59
Scratcher
27 posts

How to make an object go to another sprite's position and adjusting with size.

ok, so how about
(Sprite 1)
When green flag clicked
forever
Set XposS1 to XPos
set size to XposS1 - XposS2
end

(Sprite 2)
When Green Flag Clicked
forever
Set XposS2 to Xpos
Set Size to XposS1 - XposS2

This will set their size to their distance apart.
Silencer59
Scratcher
27 posts

How to make an object go to another sprite's position and adjusting with size.

I have made a game along these lines, though i was originally wrong, simply 0 - the x coordinate is the size.
TromboneAndSaxophone
Scratcher
91 posts

How to make an object go to another sprite's position and adjusting with size.

I think I know what you're asking. Here's a simple solution: https://scratch.mit.edu/projects/195887194/

Make sure to read the comments

Last edited by TromboneAndSaxophone (Jan. 2, 2018 18:49:59)

Uniquename1
Scratcher
100+ posts

How to make an object go to another sprite's position and adjusting with size.

A more complicated thing i think closer to what you're hoping for.

https://scratch.mit.edu/projects/10151906/#editor

Relevant codes are mostly in field 1 and 2, and the backdrop and of course some stuff in the characters telling them how to behave much like the field.

Here is another one that seems relevant. Can't say i completely understand either one or what its called to search more about it specifically.
https://scratch.mit.edu/projects/112344159/#editor
Puwexil
Scratcher
100+ posts

How to make an object go to another sprite's position and adjusting with size.

Thank you, @TromboneAndSaxophone, thanks to everyone else who bothered to help too.
TromboneAndSaxophone
Scratcher
91 posts

How to make an object go to another sprite's position and adjusting with size.

No problem
Max_TWILIGHT_SPARKLE
Scratcher
1 post

How to make an object go to another sprite's position and adjusting with size.

Where do I find “Y position to sprite one” block?
deck26
Scratcher
1000+ posts

How to make an object go to another sprite's position and adjusting with size.

Max_TWILIGHT_SPARKLE wrote:

Where do I find “Y position to sprite one” block?
The colour tells you it's a sensing block. By default it will show as backdrop# of Stage,
CheatingBambi500
Scratcher
1 post

How to make an object go to another sprite's position and adjusting with size.

but then how do i go to pos
ScratchBoy179
Scratcher
91 posts

How to make an object go to another sprite's position and adjusting with size.

Puwexil wrote:

Like, if i put something like
set y to (([yposition v] of [Sprite1 v]) - (50))
Assuming these two different objects are the same size, when you make the sprite bigger, they're gonna look closer to each other, and more apart when making it smaller.
How do I make to adjust to the size of the sprite?
I had a same problem
Here is script. (Positions aren't affected by size)
set size to (wanted size) %
go to x: ((wanted x) * ((size) * (0.01))) y: ((wanted y) * ((size) * (0.01)))

Last edited by ScratchBoy179 (Nov. 15, 2021 17:29:04)

Powered by DjangoBB