Hello, I need help, I don't know how to make a sprite collide with another sprite and return in the same direction, that is, the sprite that moves bounces with one that is fixed and returns, I need help as soon as possible, it is for a job, thank you very much (if you can explain it to me by giving me the code that would be great)
Welcome.
Have you read and tried the examples regarding Sprite collisions here
Show us what you tried and someone might help with specific recommendations.
Hello, what happens is that I really don't understand anything, I only know that I have managed to make the sprite that is moving collide with the one that is fixed and reset its position, but what I need is for it to simply collide with the fixed sprite and it will return. thank you
- ImageSprite shows you what you can do with the sprite using Blocks.
You will need one or more of these
Methods
Bounce(edge)
Makes this ImageSprite
bounce, as if off a wall. For normal bouncing, the edge
argument should be the one returned by EdgeReached
.
CollidingWith(other)
Indicates whether a collision has been registered between this ImageSprite
and the passed other
sprite.
MoveIntoBounds()
Moves the sprite back in bounds if part of it extends out of bounds, having no effect otherwise. If the sprite is too wide to fit on the canvas, this aligns the left side of the sprite with the left side of the canvas. If the sprite is too tall to fit on the canvas, this aligns the top side of the sprite with the top side of the canvas.
MoveTo(x,y)
Moves the ImageSprite so that its origin is at the specified x
and y
coordinates.
MoveToPoint(coordinates)
Moves the ImageSprite so that its origin is at the specified x and y coordinates.
PointInDirection(x,y)
Turns this ImageSprite
to point toward the point with the coordinates (x, y)
.
PointTowards(target)
Turns this ImageSprite
to point towards a given target
sprite. The new heading will be parallel to the line joining the origins of the two sprites.
Which of the blocks depends on what you coded so far. If you share your Project aia file someone will probably give you specific advice. You probably will need to MoveTo after your collision.
How can I share it with you? (it's an ugly game, so don't hate it)
To make a sprite reverse direction, set its direction to 180 + its old direction.