Discuss Scratch

mrsteve
Scratcher
100+ posts

Mouse down to drag object works in "see inside" but not on project page

In project Guess My Balance

The orange triangle is supposed to move on mouse down. It works when I am in “see inside” but, when I am on the project page no matter where I click it moves from under the mouse and I can not drag it.
The behavior in “see inside” works well, where the code
set x := mouse x
set y := mouse y

Allows me to drag as I would expect and the Scratch code seems to adjust based on where I click rather than setting the “center origin x,y”. That said, I assume you have special code to handle when in mouse down script.

Last edited by mrsteve (Jan. 21, 2013 04:19:48)


“If you give a child an answer, you solve a problem for a day,
If you teach a child to find the answers, you prepare her for life.”
- Mr. Steve's Science
nXIII
Scratcher
1000+ posts

Mouse down to drag object works in "see inside" but not on project page

That's not a bug. In the editor, you can always drag sprites to help you position them as you're making your project. That's what's happening when you drag something in the editor. In the player, that doesn't happen, so your script activates. The problem is that your sprite's costume center is off of the sprite itself, so setting the sprite's X and Y to the mouse-pointer's X and Y moves it off of the mouse-pointer. If you edit the costume and put the costume center inside of the triangle, it should work as expected.

nXIII · GitHub
mrsteve
Scratcher
100+ posts

Mouse down to drag object works in "see inside" but not on project page

But, I did check the costume for the sprite and it is in the center, yet it still has the same problem when I click on it in the project page.

And yes your right it is dragging, must be late an I'm tired.

Last edited by mrsteve (Jan. 21, 2013 04:39:53)


“If you give a child an answer, you solve a problem for a day,
If you teach a child to find the answers, you prepare her for life.”
- Mr. Steve's Science
mrsteve
Scratcher
100+ posts

Mouse down to drag object works in "see inside" but not on project page

My bad, You were right my costume center was off. When I clicked on the triangle in the I saw a “box” displayed with a circle at the center. I assumed that was the costume center. I was able to shift click on that circle and move it and assumed that changed my costume center. I fixed it and it now works (as long as I don't move the mouse too quickly.

“If you give a child an answer, you solve a problem for a day,
If you teach a child to find the answers, you prepare her for life.”
- Mr. Steve's Science

Powered by DjangoBB