• @a1ph4b3ta as adviced by @JonB

    import scene from math import pi class Game(scene.Scene): def setup(self): x = 0 while True: if x >= self.size.height: break spike = scene.SpriteNode('plf:Tile_Spikes', position=(x, self.size.height)) spike.anchor_point = (0.5,-1.0) spike.rotation = pi self.add_child(spike) #self.spikes.append(spike) x += 64 scene.run(Game())
  • Thanks, yeah makes sense. I just wondered if there was an 'official' online location, but that will certainly work for what I want.

    Thanks

  • Thank you so much. This is excellent.
    Really appreciate the help and the time you’ve taken to respond.
    Thanks 😄😄

  • @JonB said:

    a=[1,2,3]
    b=a
    b.append(4)
    a
    [1, 2, 3, 4]

    I had a similar problem so I change the a to a tuple and the copied it to b. I needed to pop() from b but keep a unchanged so I can reset it to b at start over in my script

    a=(1,2,3)
    b=list(a)
    b.append(4)
    a
    [1, 2, 3]

  • @Cethric made a full GLKit wrapper, which might do what you want.
    In scene, you will be limited to converting each frame to .jpg by using the SceneView screen capture method, i think, since there is no way to get data out of a shader.

  • I just realised the error. It’s meant to be Rect(self.player.position.x-12, self.player.position.y-12, 24, 24) I forgot the .x on the end of position. Thanks for making me notice it!

  • Thanks, it’s working now!

  • Hi, I agree with @runjaj and understand @ahp378 point of view. I would add:

    have in mind a practical problem to solve with Pythonista (a program to calculate something, or a graphical app with keys and text fields, or a game, ...) divide the practical problem in little problems (if possible) learn to solve the little problems (before independently that is easier and then by linking them together to recreate the main big problem of point 1) by:
    a. searching for an existing piece of code that solves the little problem 'x' (a big database of Pythonista scripts is this by @tdamdouni). if the piece of code solves your problem ok, if not try to modify it by changing numerical values or easy parts (with an empirical approach, and if the piece of code is well commented, it is easier).
    b. if you can't find existing pieces of code, starting to read documentation having in mind that it could be not updated or incomplete (but it is very big).

    The best documentation could be in my opinion a big with easy to find/search feature database of common recipes/pieces of code for all Pythonista features (objc, scene, sound, location, console, etc...). The big database (the one by tdamdouni is an example) would be created and maintained by people with different curiosities and interests, in this way community could help itself about common pieces of code and without bothering the only person who maintains the Pythonista software and its big documentation (@omz).

    Bye

  • @Drizzel, I was thinking about getting 100% accurate detection by first doing the rectangle intersection, and if that indicates a possible hit, then placing shape 1 on a canvas in memory, then ”deleting” the non-transparent pixels of shape 2 (also properly placed). If the end result does not equal the original, you have a hit.

  • got it. ios really has no native support for svg.
    PNG, JPG or PDF are what you will want to use.

    For single color, one option is to use a font creation tool (there are many) that let you convert your svg to a svg font, then use svg2ttf to convert to a ttf font, which can be installed systemwide, or can be loaded temporarily in app. Then, you can create images from the glyphs. Not really worth it in my opinion...

    Another option which looks promising but i have not explored yet:
    https://github.com/Kozea/CairoSVG can parse svg to produce a tree object, which then uses
    https://github.com/Kozea/cairocffi/ to convert to png. cairocffi might work without modification, or a small few, since it relies on ffi in a similar way that objc_util does, and i think the ios cairo is similar if not identical to the mac version. If not, you might also be able to use that tree to write your own output to ui.Path commands in an ui.ImageContext, and get_image provides the ui.Image.

    A final option -- convert svg to vector PDF. I believe ui.Image.from_file can read pdf. I don't know hw they compare size wise.. some programs might add a lot of garbage to a pdf, ImageMagick probably would do it well.

  • Ok thanks. Will give it a try

  • If your scene is a subview to a scrolview, it won't be directly addressable from the root scene.

    v['scrollview1']['sceneview1']

    Should work, depending on what you named things..

  • https://github.com/elff1493/pyscene, still a wip

  • Great, and you both :)

  • @JonB Thank you, gonna se if I can xome up with some kind of function to be called

  • Layers really are not required anymore -- this used to be a way to move groups of items together, but with spritenodes you can do the same by assigning as a child of another Node.

    If you just want to get the stacking order, use SpriteNode's z_position.

  • Update is automatically called for presented Scenes. A standard approach is then to do within your scene update:

    for node in self.children: if hasattr(node,'update'): node.update()
  • You basically have to implement a physics system with a gravity component.

    Here is a simple example. Change the initial velocity to change angle of arc.
    https://gist.github.com/563cf7498dda79c3ca824b12a9103e5a

  • @cvp Thank you, that did the trick!!!

Internal error.

Oops! Looks like something went wrong!