omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. jellybeard

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 1
    • Controversial 0
    • Groups 0

    jellybeard

    @jellybeard

    1
    Reputation
    232
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    jellybeard Unfollow Follow

    Best posts made by jellybeard

    • RE: Execute a series of actions on touch

      Thanks for the replies.

      I tried a sequence (see updated example above) but it looks as if calling a method (fire_laser) doesn’t count as an action as I get an error. The ship still fires three at once.

      I tried your example too and that’s close to what I am after! The lasers stop mid flight on touch end.

      posted in Pythonista
      jellybeard
      jellybeard

    Latest posts made by jellybeard

    • RE: Execute a series of actions on touch

      Thanks for the replies.

      I tried a sequence (see updated example above) but it looks as if calling a method (fire_laser) doesn’t count as an action as I get an error. The ship still fires three at once.

      I tried your example too and that’s close to what I am after! The lasers stop mid flight on touch end.

      posted in Pythonista
      jellybeard
      jellybeard
    • Execute a series of actions on touch

      How can I execute a series of actions on a single touch? For example, if I have this example from the Pythonista documentation but I want to shoot say 3 lasers, one right after the other or with a slight pause between. I tried adding the three lines defining the laser, it’s action, and it’s sound in a loop, but instead of firing the lasers in succession it fired all three at once.

      Second question, is there a “do while touch” method that would repeatedly fire lasers while the touch is held?

      EDIT:
      Updated script to include Action.sequence. I get an error that the action sequence does not include any actions.

      
      from scene import *
      import sound
      import random
      import math
      
      class MyScene (Scene):
      	def setup(self):
      		self.background_color = 'midnightblue'
      		self.ship = SpriteNode('spc:PlayerShip1Orange')
      		self.ship.position = self.size / 2
      		self.add_child(self.ship)
      
      	def update(self):
      		x, y, z = gravity()
      		pos = self.ship.position
      		pos += (x * 15, y * 15)
      		# Don't allow the ship to move beyond the screen bounds:
      		pos.x = max(0, min(self.size.w, pos.x))
      		pos.y = max(0, min(self.size.h, pos.y))
      		self.ship.position = pos
      
      	
      	def touch_began(self, touch):
      		self.run_action(Action.sequence(self.fire_laser(),self.fire_laser(),self.fire_laser()))
      	
      	def fire_laser(self):
      		a=random.random()*500-250
      		laser = SpriteNode('spc:LaserBlue9', position=self.ship.position, z_position=-1, parent=self)
      		laser.run_action(Action.sequence(Action.move_by(a, 1000), Action.remove()))
      		sound.play_effect('arcade:Laser_1')
      
      
      posted in Pythonista
      jellybeard
      jellybeard