Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Referencing a sprites own position
- tangallio
- New to Scratch
2 posts
Referencing a sprites own position
Hi Scratchers!
I am running a school SCRATCH club and hit an issue today that threw me for a few minutes. At the start of the course (6 weeks ago) I wrote the following code, but in class it was not possible to do the same thing today.
In Sprite Fish2:
6 Weeks ago this worked. I have the code here http://scratch.mit.edu/projects/17179618/ which still works.
Problem is, when creating the code now it is not possible to self-reference the position of a Sprite from within that same Sprite i.e. If I am in Fish2, there is no dropdown for Fish2 in the sensing variable I am using (y position). All other sprites are possible options, but not itself. If I go to my existing code and select the dropdown Fish2 is no longer an option.
Workaround is to create
Guidance welcome.
Thanks
Tangallio
I am running a school SCRATCH club and hit an issue today that threw me for a few minutes. At the start of the course (6 weeks ago) I wrote the following code, but in class it was not possible to do the same thing today.
In Sprite Fish2:
go to x: (-260) y: (pick random (-150) to (160))
glide (pick random (2) to (3)) secs to x: (300) y: ([y position v] of [Fish2 v])
6 Weeks ago this worked. I have the code here http://scratch.mit.edu/projects/17179618/ which still works.
Problem is, when creating the code now it is not possible to self-reference the position of a Sprite from within that same Sprite i.e. If I am in Fish2, there is no dropdown for Fish2 in the sensing variable I am using (y position). All other sprites are possible options, but not itself. If I go to my existing code and select the dropdown Fish2 is no longer an option.
Workaround is to create
([ y position v] of [Fish2 v])in Fish1 then cut and paste it via backpack into Fish2. This works but if it is not approved and there is a more valid method (create and populate a ypos var perhaps), I would prefer to communicate this.
Guidance welcome.
Thanks
Tangallio
- tangallio
- New to Scratch
2 posts
Referencing a sprites own position
*Facepalm* Indeed it does Dan. Looks like I had overcomplicated my original code and this would have been the right way to do it in the first place.
Many thanks
Carl
Many thanks
Carl
- VilladeOnScratch
- Scratcher
51 posts
Referencing a sprites own position
Hey I know this is literally from 2014 buut I'm having the same issue except when it starts as a clone I want it to change the position of its original self instead of the clone, basically from the clones side it wants to change the original non clones position and it can't really do that since there's no option to just like that issue
- deck26
- Scratcher
1000+ posts
Referencing a sprites own position
Please post a new topic instead of necroposting. Hey I know this is literally from 2014 buut I'm having the same issue except when it starts as a clone I want it to change the position of its original self instead of the clone, basically from the clones side it wants to change the original non clones position and it can't really do that since there's no option to just like that issue
- Discussion Forums
- » Help with Scripts
- » Referencing a sprites own position