• How about this slight modification to the original -- should prevent the lasers from disappearing when touch ends. Also, keeps track of the lasers for use in hit detection

    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) self.lasers=[] 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): laser_animation=Action.repeat_forever(Action.sequence(Action.call(self.fire_laser), Action.wait(0.1) ) ) self.run_action(laser_animation, 'laser') def touch_ended(self,touch): self.remove_action('laser') def remove_laser(self,laser): del self.lasers[laser] def fire_laser(self): a=random.random()*500-250 laser = SpriteNode('spc:LaserBlue9', position=self.ship.position, z_position=-1, parent=self) self.lasers.append(laser) laser.run_action(Action.sequence(Action.move_by(a, 1000), Action.remove(), Action.call(lambda:self.remove_laser(laser)))) sound.play_effect('arcade:Laser_1')
  • @nerdtron Thanks, I know the console displays the whole text.

    I was just wondering if there is an easy way to place print commands with coordinates into a scene wirhout having to use labelnodes.

    The old 8 Bit Basic dialects had this, and for Python being a mental descendant of this programming Culture I wish there was the same easy approach.

  • Thanks for the replies! Will dig into these and see what I can get working.

  • Thanks for the replies! After reading them a few times and experimenting I think I'm understanding it now.

    To create and position a rect using paths, I'm creating it with ui.Path.rect() and just giving 0,0 for the position with the desired size. Then I'm setting the position property to locate the center where I want it.

    Seems to be working, thanks for the help!

  • @cvp, thanks, that worked.

  • It worked!!
    I could stop Action.repeat().
    Thank you so much!!

  • And try the last script of this topic to get a Blurr effect.

  • @resserone13, for your app, this could work really well:

    PageControl

  • I put this code under touch_began() and its how I want. Every time the button is clicked the amount of taps is checked and if it meets the condition it adds 15 to the time.

    if self.tap_count % 20 == 0 and self.tap_count != 0: self.timer_value += 15
  • @mikael ok. That’s a good idea. I’ll add some.

  • @JonB thanks. I defined everything and added the music code and it’s stopping and starting on cue. Thank you for your help. I wasn’t sure how to use the stop resume and pause. I sometimes still have trouble figuring out little things.

  • @JonB Thank you for the advice. I’m going to try to work this in. I am also going to review all of my post to make sure I haven’t missed any advice. I really appreciate you guys helping me. I’ve seen some things you guys have worked on on github and it is much above my level. I appreciate you guys taking the time to help me. I feel it’s a privilege to be helped by people who know so much. Thank you very much @mikael @ccc @cvp.

  • @cvp I’ve got it to work with all the other sound effects by using the sound.playeffect(). I think there might be a problem when you use sound.player() with sound.playeffect(). This is what I’m using.

    class MainScene (Scene): def setup(self): bg_music = sound.play_effect('3 card monte beat (90.00 BPM) - MAIN OUT.wav', volume=.25) bg_music.looping = True
  • @resserone13 This was helpful. Was having difficulty with creating delays and this cleared it up. Thanks for the pointer. Cheers.

  • @ccc would something like this be a good idea?

    position = (self.size.w/2, self.size.h * 1.60)

    If not would be so kind to so me the proper way.

  • @resserone13, it is a feature of scene that in the setup method we already know the size. Very convenient when compared to the ui module.

  • @trey, one idea would be to place a transparent view on top (as a subview of scene.view) to handle the touches.

    Then you would need to check if the touch is near the top-right corner to simulate clicking on the ”x” with superview.close(). And remember to flip the y coordinate before passing the coordinate and touch type to your scene code. And maybe go via screen coordinates if you do a lot of zooming and panning in your scene.

  • Sounds great! Looking forward to it.

  • Thanks guys, I will study about shader and effect more Thanks!

  • @Tonnoaw I would also try to import game_menu.py and build a menu with title and option selection buttons. So, rather than setting “cheat” mode in the script, define a mode button for a non-programmer to change mode of operation.

Internal error.

Oops! Looks like something went wrong!