omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    action spritenode scene
    2
    5
    3754
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Bjucha
      Bjucha last edited by

      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

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        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 1 Reply Last reply Reply Quote 0
        • Bjucha
          Bjucha @ccc last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by 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 1 Reply Last reply Reply Quote 0
            • Bjucha
              Bjucha @ccc last edited by

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors