I'm trying to make an object stop a movement when your "x position" is equal to "x position" of other object. But this is not working... there is other way?
PS.: They are in movement from opposite sides, in opposite directions.
from already thank you.
when gf clicked change [defeateds] by (0) go to x:(250) y:(-122) change costume to [dragon1-b] appear slip in (3) seconds to x: ([position x] of [ele1]) y: ([position y] of [ele1]) repeat until<([position x] of [dragao] = ([position x] of [bola]))> change costume to [dragon1-a] say [GRRRR!!!] for (0.3) seconds slip in (0.3) seconds to x: ([position x] of [dragao]) y: (-210) disappear change [defeateds] to ((defeateds) + (1)) stop command end
Offline
Hi there -
There are a couple ways to check if the X positions are equal. First, you could assign each sprite's X Position to a variable and check if variable A is equal to variable B.
Second, you can use the block " [ X Position ] of [ Sprite ] " Which can be found under "Sensing", 5th block from the bottom, just above "Loudness" and below "Timer" Then simply check of the X position of the current sprite is equal to the position of the other sprite. (Check if it's equal using the green "Operator/Logic" blocks)
By the way, at the top of your code, you might want to make it "set defeateds to 0" rather than "change defeateds by 0", otherwise your game will not play properly after the first loss.
Happy scratching,
- iNK
Offline
The problem may be that your sprites are never exactly equal to each other's x positions. For example:
sprite 1 sprite 2
Frame 1: -15 10
Frame 2: -5 0
Frame 3: 5 -10
Frame 4: 15 -10
I'd either use the "<touching []?>" block or check for a range of values rather than a specific number, like this:
repeat until<(([abs v] of ([x position v] of [other sprite v])-(x position))) < (5)> your movement code endedit: blocks look bad but I've got to go, sorry!
Last edited by MoreGamesNow (2013-01-08 19:11:09)
Offline
MoreGamesNow wrote:
The problem may be that your sprites are never exactly equal to each other's x positions. For example:
sprite 1 sprite 2
Frame 1: -15 10
Frame 2: -5 0
Frame 3: 5 -10
Frame 4: 15 -10
I'd either use the "<touching []?>" block or check for a range of values rather than a specific number, like this:repeat until<([abs v] of (([x position v] of [other sprite v])-(x position))) < (5)> your movement code endedit: blocks look bad but I've got to go, sorry!
Fixed.
Offline
ErnieParke wrote:
MoreGamesNow wrote:
The problem may be that your sprites are never exactly equal to each other's x positions. For example:
sprite 1 sprite 2
Frame 1: -15 10
Frame 2: -5 0
Frame 3: 5 -10
Frame 4: 15 -10
I'd either use the "<touching []?>" block or check for a range of values rather than a specific number, like this:repeat until<([abs v] of (([x position v] of [other sprite v])-(x position))) < (5)> your movement code endedit: blocks look bad but I've got to go, sorry!Fixed.
Thank you
Another thing to note is that you're spending about 0.6 seconds executing commands. That means the "repeat until" block only checks once every 0.6 seconds. Depending on the kind of "reaction time" you want from the computer, this may interfere.
Offline
MoreGamesNow wrote:
ErnieParke wrote:
MoreGamesNow wrote:
The problem may be that your sprites are never exactly equal to each other's x positions. For example:
sprite 1 sprite 2
Frame 1: -15 10
Frame 2: -5 0
Frame 3: 5 -10
Frame 4: 15 -10
I'd either use the "<touching []?>" block or check for a range of values rather than a specific number, like this:repeat until<([abs v] of (([x position v] of [other sprite v])-(x position))) < (5)> your movement code endedit: blocks look bad but I've got to go, sorry!Fixed.
Thank you
Your welcome!
Offline
Why is two posts asking the same thing about this post that posts, and I put a post on about that, that my post, was your post which is the same post but a little bit less information in my post, which my post has less informantion but I figured it out on that post but there is more posts with more information on what this post is all about posts which is better than my post, than your post, so this this is your post, and my post, which got the same posts that post on your post and my post.
Nothing else.
Last edited by fetchydog567 (2013-01-11 18:46:32)
Offline