• I am not an expert here, but I think the power of transforms is that you'd leave the frame where it should end up (or even use a pyui, with the as-presented configuration), then use transforms only to move the view. I think that might save one or two lines.

  • The following code creates a rectangular grid of 64 cells (8*8) with different colors. If you touch a cell, it changes the color. I hope this gives you an idea of how to solve your problem with shader. The following online book explains how to create such shaders.
    http://patriciogonzalezvivo.com/2015/thebookofshaders/

    import scene, ui shader_text = ''' precision highp float; varying vec2 v_tex_coord; uniform sampler2D u_texture; uniform float u_time; uniform vec2 u_sprite_size; uniform float u_scale; uniform vec2 u_offset; void main(void) { vec2 uv = mod(v_tex_coord, .125); vec2 invuv = uv*8.; vec2 pq = floor(v_tex_coord*8.0)/8.; //vec4 color = texture2D(u_texture, invuv); vec2 t = floor(u_offset*8.0/(u_sprite_size))/8.; float r = 0.; if ((pq.x == t.x) && (pq.y == t.y)) r = 1.0; vec4 color = vec4(pq.x, pq.y, r, 1.); gl_FragColor = color; } ''' class MyScene (scene.Scene): def setup(self): tile_texture = scene.Texture(ui.Image.named('Snake')) self.sprite = scene.SpriteNode( tile_texture, size=(600, 600), anchor_point=(0,0), parent=self) self.sprite.shader = scene.Shader(shader_text) self.sprite.position = (100, 100) def touch_began(self, touch): self.set_touch_position(touch) print (self.sprite.shader.get_uniform('u_offset')) def set_touch_position(self, touch): dx, dy = touch.location -self.sprite.position self.sprite.shader.set_uniform('u_offset', (dx, dy)) scene.run(MyScene(), show_fps=True)
  • Also works on iPhone 6s. It feels a lot snappier. Even though I have Pythonista on my phone, I have never used it for other than testing. But when you are coding who needs animations with the programming interface.

    Can also confirm, if you do a hard shutdown of Pythonista, on relaunch everything is back to original. That's why I have put mine in the pythonista_startup.py (1.6 only)

Internal error.

Oops! Looks like something went wrong!