Beta Status Update
misha_turnbull last edited by
@JonB here is the code I'm using now, have restarted Pythonista many times and can't think of any other changes I've made other than removing
light.alpha = 1:
# coding: utf-8 import sk import random MAXSPD = 700 MAXLIFE = 10 TEXTURE = 'shp:Circle' MINLIFED = -120 MAXLIFED = 120 SCALE = 2 decayrate = 0.005 collider_f = 0.3 def randvec(maxspd): return (random.randint(-maxspd, maxspd), random.randint(-maxspd, maxspd)) particle_tpl = sk.SpriteNode(sk.Texture(TEXTURE)) particle_tpl.name = 'particle' particle_tpl.color_blend_factor = 1 particle_tpl.age = 0 particle_tpl.lighting_bit_mask = 1 particle_tpl.x_scale = SCALE particle_tpl.y_scale = SCALE particle_tpl.alpha = 1 particle_tpl.shadow_cast_bit_mask = 1 physics = sk.PhysicsBody.circle(particle_tpl.size.x/2 * collider_f) physics.restitution = 1.2 physics.affected_by_gravity = False physics.allows_rotation = True physics.mass = 0.3 physics.pinned = False physics.angular_velocity = 0 physics.category_bit_mask = 1 physics.contact_test_bit_mask = 1 particle_tpl.physics_body = physics class Game (sk.Scene): def __init__(self): sk.Scene.__init__(self) self.name = 'scene' self.img = sk.Texture(TEXTURE) self.maxspd = MAXSPD self.handles_node_touches = False self.maxlife = MAXLIFE * 60 # convert to frames self.background_color = (0, 0, 0) self.lighting_bit_mask = 1 # init walls walls = sk.Node() walls.position = (0, 0) physics = sk.PhysicsBody.edge_loop_rect(0, 0, 1024, 768) physics.dynamic = False physics.restitution = 1.1 walls.physics_body = physics self.add_child(walls) # lighting light = sk.LightNode() light.position = (10, 758) light.shadow_color = (1, 0, 0) light.ambient_color = (0, 0, 1) light.light_color = (0, 1, 0) light.enabled = True light.category_bit_mask = 1 light.falloff = 1 light.name = 'light' self.add_child(light) def update(self): for p in self['particle']: p.age += 1 if p.age >= p.lifespan: # if exceeded life, reduce alpha by 1 p.alpha -= decayrate if p.alpha <= 0: p.run_action(sk.Action.call(p.remove_from_parent)) def touch_began(self, node, touch): self.selected = None new = particle_tpl.__copy__() new.physics_body = new.physics_body.__copy__() new.lighting_bit_mask = 1 new.position = touch.location new.physics_body.velocity = randvec(MAXSPD) new.color = (random.random(), random.random(), random.random()) new.lifespan = self.maxlife + random.randint(MINLIFED, MAXLIFED) new.alpha = 1 self.add_child(new) def touch_moved(self, node, touch): self.touch_began(node, touch) def did_begin_contact(self, collison): if collison.body_a.node.name == 'particle' and collison.body_b.node.name == 'particle': collison.body_a.node.color = (random.random(), random.random(), random.random()) collison.body_b.node.color = (random.random(), random.random(), random.random()) def main(): game = Game() scene_view = sk.View(game) scene_view.shows_fps = True scene_view.shows_node_count = True scene_view.present() return game if __name__ == '__main__': g = main()
However, it still just gives me a black screen. As before, when I touch the screen the node count goes up but I cannot see anything.
I can see the balls appear just fine with your code on ios 8.2 on ipad2. For the platformer game I had a similar problem which was solved by rotating the display. You might try running it, then rotating the device so that it tries to resize.
ccc last edited by
The code above works for me.
dgelessus last edited by
Not sure if this is a bug or an odd feature, but Pythonista strips all whitespace (including trailing newlines) from the end of a file when it is saved. This only becomes apparent when closing the editor tab for that file or restarting the app. If this is intentional, it would be nice if this were optional.
ccc last edited by
In the beta release
ui.View().present(orientations=['landsacpe'])is not forcing the view to display in landscape mode. It is just me or are others seeing the same behavior?
Helgi last edited by
Can somebody among the beta users tell me whether the extensions can be made to handle files (e.g., Mail attachments) in a way that was possible with Open In?
The scenario I used in the days of Open In was this: I have an email attachment of specific type (e.g., .txt), I open it in Pythonista, the Open In handler then performs some automated actions (in my case, uploads it via SCP and then runs several commands on the remote server). Can this be done with the extensions now? Should I wait for the new release or try and find other ways to do this?
That's exactly what the extensions let you do.
Webmaster4o last edited by
How can I sign up for the test flight beta? I want to try it, looks AMAZING.
userista last edited by
Modules that are in site-packages are not importable when in the app extension. Is this expected behavior?
The extension runs in its own sandbox.. As I recall there was an extensions site packages? You have to separately install packages to both locations.