• @JonB Not bad at all for an admin πŸ˜‚
    Sorry, I could not stop myselfπŸ˜‡

  • Thanks, it’s working now!

  • Hi @ETPH. Couple of generic advices:

    Do not use magic constants in your code (like position_options) in multiple places, it's a nightmare when you want to change them. Move them outside of create_tile, touch_began and reuse them there. Like MARGIN_OF_ERROR. Keep your functions / methods short. It's good when they can fit one screen (well, depends how the screen is big :), but you know what I mean. Not a hard rule, but it's about readability and crunching all these bugs quickly. It's easier when it's short. touch_moved is very long and overly complicated. You shouldn't hardcode positions based on your device in case you want to run it on iPhone SE for example. Split your task into several smaller ones. Replace one huge function with many small ones doing just one thing. Again, readability & easier way how to spot a bug.

    I didn't dive into your touch_moved method, sorry. But I did quickly hack an example of generic board & moving tiles. You can find it here.

  • as I understand your code, it is not that data is getting duplicated, but you are using the same touch instance, since the touch Id is the same -- i.e you are updating the touch object, but not creating a new one. really, I think you sort of want to compute the rotation, etc parameters for each state, when the state object gets created, rather than manipulating the touch object in Data. Dunno.

    btw, the python built in debugger is called pdb, and does let you single step code, look at variables in real time, etc. But it is not really useful within scene, since it is console based. I am not sure if scene is compatible with the long press to set breakpoints in the python ista debugger.

  • Hardcore maths!
    I was looking to get a moveable line. Did you squeeze a rect and rotate it?

  • Using min() and max() simplifies keeping sprites in bounds...

    import scene class ButtonNode(scene.SpriteNode): def __init__(self, title, *args, **kwargs): scene.SpriteNode.__init__(self, 'pzl:Button1', *args, **kwargs) self.title = title scene.LabelNode(title, color='blue', font=('Avenir Next', 20), parent=self, position=(0, 0)) def touch_began(self, touch): sprite = self.parent.sprite x, y = sprite.position if self.title == '←': sprite.position = max(x - 20, 0), y elif self.title == 'β†’': sprite.position = min(x + 20, self.parent.size.w), y elif self.title == '↓': sprite.position = x, max(y - 20, 0) elif self.title == '↑': sprite.position = x, min(y + 20, self.parent.size.h) class MyScene(scene.Scene): def setup(self): center = self.size/2 self.sprite = scene.SpriteNode('Dog_Face', parent=self, position=center) ButtonNode('←', parent=self, position=center - (300, 300)) ButtonNode('β†’', parent=self, position=center - (100, 300)) ButtonNode('↓', parent=self, position=center + (100, -300)) ButtonNode('↑', parent=self, position=center + (300, -300)) def touch_began(self, touch): for node in self.children: if touch.location in node.frame and hasattr(node, 'touch_began'): node.touch_began(touch) scene.run(MyScene())
Internal error.

Oops! Looks like something went wrong!