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?
Updated script to include Action.sequence. I get an error that the action sequence does not include any actions.
from scene import *
class MyScene (Scene):
self.background_color = 'midnightblue'
self.ship = SpriteNode('spc:PlayerShip1Orange')
self.ship.position = self.size / 2
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):
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()))