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 use Action.rotate_by/to
-
I would like my object (it’s a UFO Texture object) to rotate as a UFO should.
I tried using A.rotate_by as well as A.rotate_to.
Also, I set A = Action above, so A.<actionType>() is == Action.<actionType>().
Here is the line where I am attempting to do this in the code below:actions = [A.move_to(self.size.w / 2, -25, d), A.rotate_by(2*pi, d), A.remove()]
The UFO does not rotate (as far as I can tell).
Whether I set the radians to ‘pi’ or ’2*pi’ or ‘720’ (all float/int types btw).
None of which made a difference. Oh wait I think I see it now, but will post anyway.I believe my mistake is that I am running a SEQUENCE of actions, with the rotation step being performed once it has essentially left my view. If I am incorrect, please correct me. I will try this out after work today and return back here if things don’t go as I expect. Thanks!
Here is my code:
def spawn_item(self, spawnItem = None): if spawnItem != None: if spawnItem == "spawnBoss": meteor = MeteorBoss(parent=self) self.bossDestroyed = False meteor.scale = 4.0 meteor.livesRemaining = 300 * self.stageNumber meteor.position = (self.size.w / 2), (self.size.h + 200) d = 40 sound.play_effect('digital:SpaceTrash3') actions = [A.move_to(self.size.w / 2, -25, d), A.rotate_by(2*pi, d), A.remove()] meteor.run_action(A.sequence(actions)) self.items.append(meteor)
-
Okay got it.
actions = [A.move_to(self.size.w / 2, -25, d), A.remove()] meteor.run_action(A.group(A.sequence(actions), A.rotate_by(2*pi, d)))
Did the trick!