This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-18 00:27:04

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Help!

I am having some trouble with a game I am making. I want it so the player sprite will point in the direction 90 if the mouse pointer is more on the right side of the player sprite and the player sprite will point in the direction -90 if the mouse pointer is more on the left side of the player sprite. Help please! I could not find the, direction of mouse pointer (sensing).


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#2 2011-09-18 00:56:46

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Help!

Well, there is no <direction of mouse pointer> block, because the cursor doesn't have a direction - it's just a point with an x and a y value.

Instead, just check if the mouse's x value is greater than or less than the sprite's value.

Code:

When green flag clicked
forever
    if (mouse x) > (x position)
        point in direction (90)
    else
        point in direction (-90)

Hope that helps!  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2011-09-18 12:01:42

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: Help!

Harakou wrote:

Well, there is no <direction of mouse pointer> block, because the cursor doesn't have a direction - it's just a point with an x and a y value.

Instead, just check if the mouse's x value is greater than or less than the sprite's value.

Code:

When green flag clicked
forever
    if (mouse x) > (x position)
        point in direction (90)
    else
        point in direction (-90)

Hope that helps!  smile

Thanks! Now I just need to remember which project that was in... XD


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

Board footer