"Mouse Position Inside" isn't doing what I think it should.

fogartyfogarty Member, PRO Posts: 181
edited May 2012 in Working with GS (Mac)
I'm making a game where you drag blocks around and place them on top of other target blocks. When the block types match, it changes the color of the target block. I used the "When actor receives event --> overlaps or collides with --> actor type" rule, and that works fine. When I drag a "penny" block to a "penny" target, the penny target changes color.

However, I'd actually like to make it a little tighter and have the target block change color once the dragged block is more solidly over the target block (instead of the second the two blocks overlap)...say when the mouse dragging the block is inside the boundaries of the target block.

I thought adding this command to the target block would do the trick: "When mouse position is --> inside." But adding that line makes the target block never change color, even during a collision. (It's an "All" rule, so I'm trying to say when the block types match AND the mouse position is inside the target block.)

Does the "mouse position inside" not do what I think it should?

Thanks!

Best Answer

  • scitunesscitunes Posts: 4,047
    Accepted Answer
    Here's what I think is happening. When the actors first collide the game checks that rule and says (if it could talk) - "the two are colliding but the mouse is not inside so I wont execute this rule." Once the mouse is inside it has stopped checking for that collision and so it still thinks the rule should not be executed as it doesn't know that it is still colliding. Two things to try:

    1) Split your double rule into a rule inside of another rule. like this:

    Rule: When mouse is inside
    -----Rule: When Colliding with penny
    ----------Change color

    or try this:

    2) Create a boolean called self.CollideWithPenny

    Rule: when overlaps with penny
    change attribute self.CollideWithPenny to 1

    Rule: when self.CollideWithPenny is true AND mouse is inside
    change color

    Seems like one of these should work.

    Best of luck!

Answers

Sign In or Register to comment.