Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Transformation matrix?
-
I'm having som problems with the new node system of the 1.6 beta. Is there an equivalent to the previous
scene.translate
function? -
Wouldn't you just use Node.position? Or Action.move_by?
-
I managed what I was trying to do, by using a "world node" and a "player node", the player node is just centered on the screen, while the world is the node that is actually being moved around. Now my collision detection fails, so I guess I have to use
Node.point_to_scene
orNode.point_from_scene
, but I haven't figured out how they work. -
See the new examples, such as BrickBreaker.py for ideas.
I think you want to use rect.intersects(bbox) -
I'll try to explain it a bit further.
The objects that need collision detections are circles, so I checked if the cartesian distance between the two circles were less than the player circle's radius. I used ascene.ShapeNode
as the world, that moves around the player, and that contains the other circles as child nodes. This makes the coordinates of the objects inside the world different from those in thescene.Scene
. So I think I need some way to get the coordinates relative to the screen. -
So, you could use point to scene on the circle center first. But, if all of your collision objects are direct subnodes of the world node:
scene | +-- player | +-- world node | +-- ball1 +-- ball2 +-- etc
you could basically just add the world position to the ball,positions:
hit_test(player.bbox, world.ball1.bbox.translate(world.x,world.y))
Look at BrickBreaker's hit_test()... it does a quick interescts, followed by checking the distance. You could do something similar, except that for circle to circle collission you simply compute the distance between circle centers (you can just subtract the bbox.centers, which produces a Vector2, and you can use abs to get length of the vector efficiently) and check if it is greater than the sum of radii.
-
I think that's exactly what I'm looking for! Thanks @JonB :)