How to detect where on a sprite a mouse-click occurred on scratch - sprite

So I’ve been trying to make a target type game where you click on a target and it tells you how accurate you were and where you clicked each time. After a while I have run across an issue where I couldn’t find out where on the sprite I clicked the target on. I tried googling it but all that comes up is detecting when the sprite is clicked. If anyone can help me it would be very appreciated. Thank you.

I think this is what you want: Create a variable (I'll call it accuracy). Then create an event for "When this sprite clicked". Have it set your variable to "distance to mouse pointer". This will give you the distance from the mouse click to the center of the sprite.

Related

SVG mouse event unsyncronized if window scrolled

I don't know how to properly explain this.
I have a svg element which is a big rectangle. If i scroll down, then click on my element, the click isn't registered where my mouse is, but where my mouse would be if i didn't scroll down.
So, if i scroll down by 100px and click on my rectangle, the click will be registered 100px above where i actually clicked.
It's behaving as if i hadn't scrolled down.
Edit: I'm using event.clientX and event.clientY to get the mouse position.
I'm new to svg and i don't know the right keywords to describe my problem.
I'm using svg.js, though i don't think it's relevant to the problem.
I assume this is a well known thing. Can someone point me in the right direction? What kind of keyword am i looking for here?
The problem seems simple enough, i just need to know what to search for.
Thank you.
The problem was the utilization of (event.clientX, event.clientY) to get the mouse position.
In the presence of a vertical and/or horizontal scroll, using these properties caused a mismatch between where the mouse appeared within the page and the mouse position provided by (event.clientX, event.clientY).
I was using the mousedown event, with the mousemove event to create a selection rectangle, similar to what you can find in video games. When horizontal or vertical scrolling had been applied, my selection rectangle didn't appear where my mouse was.
This was solved by using event.pageX and event.pageY (instead of clientX and clientY).
Thank you to #ccprog for pointing me in the right direction.

How can I lay a circular region on my image in ds9?

I'm working in ds9 and I need to make a circular region on my image. Everything I can find says I should be able to just left click with my mouse on the region I want the circle to be and a green circle will appear that I can then adjust. When I left click nothing happens! I've tried using my touch screen, doing this on a Mac, on Windows (my usual OS), but it's such a simple instruction I don't even know what else to try. Thanks in advance
lol I figured it out; if anyone else is having this problem make sure Region is selected on the Edit dropdown menu

Blender : Some objects disappear when I turn to camera mode (it's not the snapping I think)

OK... here is the thing...
I am modeling a Star Wars Cruiser.. I'm doing pretty fine, but.. whenever I look through the camera, half of my ship disappears ?! Now you might think it's the clipping, but that doesn't make sense, since the clipping is set to 0,1 mtr - 10.000 mtr, which should be more than enough. Besides that, the clipping is the same for both the visible and now disappeared objects...
Does anyone have any clue ?
I also tried to change the Local view to Global view.. but no dice...
Here is a screenshot in not-camera view :
And here is one in camera view : i.imgur.com/XaxAHIN.png
I'm using Blender 2.82
Please let me know if you need more info or even a link to the model...
OK, I got some help from a friend... Joshua Rooijakkers from the Netherlands...
He fixed the problem in seconds...
So ... it WAS the clipping.. the setting was just buried somewhere I didn't look...
Thanks Josh ! :-)
Objects disappear in camera view modeWhile setting up my camera with the camera lock to view option selected, I noticed that on switching on to the camera view, the object had disappeared.
I tried zooming in and out, but that did not work. I exited the camera view and then selected the object in the outliner and then tried zooming in and out and then panning down and adjusting the view in the view port. I could see that the object was now visible and that the camera was positioned below the object. That was because the camera was added wrt to the position of the cursor which was snapped to the world origin. I a sure many would have encountered such issues.
I then selected the camera to ascertain its position. Then by using the grab tool, I moved the camera along the Z axis just above the object and then switched to the camera view and selected the lock camera to
view option to adjust the camera view to the desired position.
This helped me locate my object in the camera view. Do let me know in the comments if there are other ways of dealing with this.

How can the following errors be resolve in SCRATCH?

I created a bouncing ball game in scratch for CS50 PSET0.
The game works well as I expected, except for the following bug/errors:
The game can be paused by pressing the UP Arrow key on the keyboard, even BEFORE it is started or AFTER the game is over. THIS SHOULD ONLY WORK WHEN A LEVEL HAS BEEN SELECTED AND GAME STARTED AND NOT BEFORE OR AFTER IT IS STARTED. [WORKING ON IT]
I set the Paddle dragmode to not draggable, yet it's not working as you can still drag the paddle using the mouse. [SOLVED]
Falling eggs/bomb won't stop falling when the game is over or paused. [TRYING TO SOLVE IT BROUGHT A NEW BUG] One egg appears at the bottom of the screen after I paused and resume the game. I'm not sure how to hide that one stubborn egg.
On hitting the paddle or edge, the ball bouncing isn't very smooth and natural. It sometimes lag. [WORKING ON IT]
JUST CURIOUS: Why is the code "when I receive Setting btn Clicked" not working on the sound and music button sprite? [SOLVED]
I will appreciate all your kind suggestions.
Here's my project
NB: if the question seems unclear and you tend to understand it. Kindly feel free to suggest an edit. Thanks.
For point 1, you could test with an if statement whether the game is currently running. (Using the same variable you use to pause the game.)
As for the dragging of the paddle, I can't seem to drag it. That is, I can't drag it when I am playing, but I can when in the editor. This is always the case, you can drag any sprite around while editing, but not when playing without the editor open. This is the default behaviour of sprites as well, you do not have to declare it each time. A reason for you to want to drag sprites is when you use the Pen Extension to create a drawing program.
To stop the eggs from falling, you could pause the clones the same way you pause the ball when moving.
To let the ball turn more smoothly you could let it turn between an angle from -90° to 90° opposite to the surface it hits. To implement this would be quite difficult with a single line. You could, if you don't mind it hitting the edge instead of the border you built, split it so you include the built-in block: if on edge, bounce. The if-statement would then only include the touching of the paddle (and maybe the danger bar). In this statement, you would select an angle between -90 and 90 degrees.
For 5, there must've gone something wrong when you wanted to design this, the when I receive [setting btn clicked v] block is just not connected. :)

slide-in animation while opening new applications in linux

I am looking to achieve the following :
when an application stars up, I want it to slide in from the left of the screen
Is this possible to do in linux ? How do I go about achieving it ? I could not find any resources online, so if anyone could point me in the right direction, that would be great.
I am open to programming a solution for this too. It would be great if i can get an answer on how to program something like this.
Presumably you have control over the placement of the window. Place the window off screen, then set up a loop that moves it over one pixel at a time. Exactly how to do that depends on your GUI toolkit.

Resources