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.
Convert SpriteNode position to float
-
Hello.
im trying to create a laser/missle that fires at the player ship position. But im getting type error: A float is required. When using the followingactions = [A.move_to(self.ship.position, self.ship.position, 2 * 2), A.remove()]
Is it possible to convert the self.ship.position to float somehow or is it an orher way to do it?
Thank you
-
http://omz-software.com/pythonista/docs/ios/scene.html#scene.Action.move_to
x, y = self.ship.position actions = [A.move_to(x, y, 2 * 2), A.remove()]
-
@ccc Yes been looking at that but the problem is the X,Y coordinates, seems not to accept
self.ship.position
as X,Y values if I use regular numbers it works
Guessing the problem is thatself.ship.position
has both x,y coordinates in it so theA.move_to
can't read it. -
I don't quite get it. What do you get when you
print(self.ship.position, x, y)
?What about
[A.move_to(self.ship.position.x, self.ship.position.y, 2 * 2), A.remove()]
?What about
[A.move_to(self.ship.position[0], self.ship.position[1], 2 * 2), A.remove()]
? -
@ccc so sorry didn't see your whole response, That got it to work thank you very much!!!