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.


    How to create an inverted texture of scene.SpriteNode ?

    Pythonista
    scene
    3
    7
    2667
    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.
    • ?
      A Former User last edited by A Former User

      I have a scene.SpriteNode object with the plf:Tile_Spikes texture. I put it at the top of the scene so I want to make the spikes face downwards. How can I do it ?

      Screenshot: https://imgur.com/snJXH8Z

      The part of the code which creates spikes:

      class Game(scene.Scene):
      
          def make_spikes(self):
              x = 0
              while True:
                  if x >= self.size.height:
                      break
                  spike = scene.SpriteNode('plf:Tile_Spikes', position=(x, self.size.height))
                  self.add_child(spike)
                  self.spikes.append(spike)
                  x += 64
      
      cvp 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @Guest last edited by

        @a1ph4b3ta is that ok?

                    from math import pi
                    spike.rotation = pi
        
        1 Reply Last reply Reply Quote 1
        • cvp
          cvp @Guest last edited by

          @a1ph4b3ta due to rotation you have to decrease y, I have tried with

                      spike = scene.SpriteNode('plf:Tile_Spikes', position=(x, self.size.height-50))
          
          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            @cvp It works now. Thanks a lot!

            cvp 1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              @cvp I suspect anchor_point would solve the offset issue...

              cvp 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @JonB last edited by

                @JonB I agree but I only wanted to show how to rotate

                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @Guest last edited by

                  @a1ph4b3ta as adviced by @JonB

                  import scene
                  from math import pi
                  class Game(scene.Scene):
                      def setup(self):
                          x = 0
                          while True:
                              if x >= self.size.height:
                                  break
                              spike = scene.SpriteNode('plf:Tile_Spikes', position=(x, self.size.height))
                              spike.anchor_point = (0.5,-1.0)
                              spike.rotation = pi
                              self.add_child(spike)
                              #self.spikes.append(spike)
                              x += 64
                  scene.run(Game())
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors