Ok thanks. Will give it a try
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.
Posts made by Bjucha
-
Tutorial for Action.call method?
Hello Im having a hard time getting Action.call method to work. Is there a tutorial for Scene.Action methods (except for the help documentation) I want to call the function:
def twin_action(self,twinboss): ``` Using this line of code:
blasers.run_action(A.sequence(actions), A.call(self.twin_action())) ```
But It seems that the Action.call function does not like that the twin_action takes both self and twinboss with it.
I really dont know how to fix it, any ideas/solutions?
-
RE: TypeError: Expected an Action object
@JonB Thank you, gonna se if I can xome up with some kind of function to be called
-
RE: TypeError: Expected an Action object
@JonB I got it to work! But I do still have one question, Can the start position update? As of now it looks like this:
blasers = SpriteNode('spc:LaserRed15' , parent=self) blasers.z_position = -1 a,b = boss.position blasers.run_action(A.repeat_forever(A.sequence(A.move_to(a,b), A.fade_to(1), A.move_to(10,10), A.fade_to(0))))
The problem is that the boss moves, so I though that by using ```
a,b = boss.position -
RE: TypeError: Expected an Action object
@JonB hmm, Im starting to understand it now thanks to you. Gonna see if I can get it to work,
-
RE: TypeError: Expected an Action object
@JonB But if I don’t use Action.Remove, the SpriteNode will not disappear, Since this is ”Laser” shot by an other SpriteNode I want them to move to a position then disappear and then the repeated. I thought that that the Action.Repeat_forever would run the whole process of the actions phase over and over again.
If I can’t use Action.remove() how can I make it work as I wanted?
-
RE: TypeError: Expected an Action object
Hmm still cant get it to work right.
I thought this would work:
blasers = SpriteNode('spc:BoltSilver' , parent=self) blasers.position = twinboss.position + (0, 30) blasers.z_position = -1 b = random.uniform(10.0, 250) actions = [A.move_to(b, 10, 2 * 1),Action.remove()] blasers.run_action(A.repeat_forever(A.sequence(actions)))``` But the action does not repeat, I thought that A.repeat_forever would loop actions, but is only runs once What am I missing?
-
RE: TypeError: Expected an Action object
@JonB Ah, I have been looking at it from the wrong way. I thought A.repeat_forever came after, It still does not work perfectly but At least im not getting the Type Error anymore
Thank you man, gonna see if I can get it to work as I want it to now -
RE: TypeError: Expected an Action object
@JonB hmm I thought that I just could replace sequence with repeat_forever, but are you saying that remove method can not be there?
Gonna try it and se if I can get it to work -
TypeError: Expected an Action object
Hello.
Does anybody know why I get a TypeError, when using repeat_forever method for scene.Action? If I use sequence instead it works, but I would really like to use repeat_forever.Here is the part of the code:
blasers = SpriteNode('spc:LaserRed9' , parent=self) blasers.position = twinboss.position + (0, 30) blasers.z_position = -1 b = random.uniform(10.0, 250) actions = [A.move_to(b, 100, 2 * 1), A.remove()] blasers.run_action(A.repeat_forever(actions)) self.blasers.append(blasers)
But if I use:
blasers = SpriteNode('spc:LaserGreen13' , parent=self) blasers.position = twinboss.position + (0, 30) blasers.z_position = -1 b = random.uniform(10.0, 250) actions = [A.move_to(b, 100, 2 * 1), A.remove()] blasers.run_action(A.sequence(actions)) self.blasers.append(blasers)
It works fine, happy for any help...
-
RE: Scene.update() for classes
@JonB Yeah I thought that having a update within the enmey appear function would work but nothing happens, But the update for Galaxy(Scene) does work and updates the function so I use it. Thanks
-
Scene.update() for classes
Hello everybody, Im trying to get a SpriteNote class to have a function with a nested Scene.update() funnction. However it does not work, Does anybody know why or maybe is not possible for classes to have update()?
Here is the codefrom scene import * A = Action class Enemy (SpriteNode): def __init__(self, **kwargs): SpriteNode.__init__(self, 'spc:EnemyBlack4', **kwargs) class Galaxy (Scene): def setup (self): self.background_color = '#0c1037' self.test = [] self.blasers = [] def update(self): self.enemy_appear() def enemy_appear(self): enemy = Enemy(parent=self) enemy.position = (355,540) self.test.append(enemy) def update(self): blasers = SpriteNode('spc:LaserBlue11', parent=self) blasers.position = enemy.position + (0, 30) blasers.z_position = -1 actions = [A.move_to(5, 100, 2 * 5), A.remove()] blasers.run_action(A.sequence(actions)) self.blasers.append(blasers) run(Galaxy())``` Happy for any help
-
RE: Need hellp with Ui.View.close method
@cvp thanks but now it says that ’main_view’ is not defined. When pressing the button.
-
Need hellp with Ui.View.close method
Hello I have added a ui.view on my scene that is displayed when my game starts, and at the same time the Scene.Paused = True condition is activated. Here is The problem I want a button that when presse closes the ui.view using ui.view.close and starts the scene, however I cant get the ui.view.closee to work. I always get that main_view (name of the ui.view) is not defined in the button pressed function. I here is the code ```
class view (ui.View):
main_view = ui.View(name = 'Killer Aliens From Space!')
main_view.present(title_bar_color = 'grey')def startup(sender): Scene.paused = False ui.View.close(main_view) # Here is where it complains b1 = ui.Button(title = "Start") b1.frame = (295,390,190,50) b1.background_color = '#b03206' b1.corner_radius = 15 b1.tint_color = 'blue' b1.action = startup main_view.add_subview(b1)
Any ideas why this is happening?
-
SpriteNode movement trouble
Hi
Im having a problem with getting my SpriteNode to move several times
Moving it from one place to an other is no problem but if I would like it to make a new movement when the first one is complete it will not work
This is how I tried:def mini_attack(self, boss3): mini = Mini(parent=self) mini.position = boss3.position x,y = self.ship.position action = [A.move_to(300,300, 1.5)] mini.run_action(A.sequence(action)) mini.remove_action(A.sequence(Action)) if mini.position == (300,300): action2 = [A.move_to(x +10,y + 20, 1.5)] mini.run_action(A.sequence(action2)) ``` it's the action2 that will not happen... Appreciate any help
-
RE: Kill all Aliens!
@JonB yes, I want the ship to "die" if it touches the explosion, gonna try your solution when I get home, thank you
-
RE: Kill all Aliens!
@ccc thanks for the help, but I stll don't get it to work maybe I have forgotten something else. Anyhow thank you for your help will look through it all again
-
RE: Kill all Aliens!
Hi everybody.
I have a problem with a function and Im wondering if anybody can help me with it
I have create "Bombs" that explode if you shot them, however my issue is that I would like the ship to die if it touches the explosion and I thought that it should look something like this for it to work:def bomb_gone(self, bomb): explode = SpriteNode('shp:Explosion00', parent=self) explode.scale = 0.5 explode.position = bomb.position if self.ship.position == explode.frame: exit() explode.run_action(A.move_by(10, 10, 1.6, TIMING_EASE_OUT)) explode.run_action(A.sequence(A.wait(1), A.remove())) bomb.remove_from_parent()
as you can see if the ships and explode occupies the same frame the game is over, but it does not work, it works if the "bomb" has not exploded and I fly right into it but not if they explode, any suggestions?