Forum Archive

Convert SpriteNode position to float

Bjucha

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 following actions = [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

ccc

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()]
Bjucha

@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 that self.ship.position has both x,y coordinates in it so the A.move_to can't read it.

ccc

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()]?

Bjucha

@ccc so sorry didn't see your whole response, That got it to work thank you very much!!!