• @ccc

    I remember seing this a while back and a couple games became helpful for referencing. but i had to go to other websites and translate what they would say about SceneKit so that it made since for scene. if it wasnt for my previous experience with C# and a few third party engines i would of been completly lost.. I just feel it would be helpfull for current and future Pythonistas to have an isolated source to handle such topic. Game Development has been a wonderfull journey this past 8 years or so but by no means has it been easy lol.

  • @cvp - that’s a tremendous help, many thanks.

    For anyone who might want help with ui and scene path drawing when searching in the future, here’s the complete working code (when using the ‘new’ render loop not the classic render loop):

    import ui from scene import * class MyScene (Scene): def setup(self): self.background_color = '#00006b' self.centre = Point(self.size.w/2, self.size.h/2) def update(self): pass def touch_began(self, touch): # Calculate vector between centre point and touched point dx = touch.location.x - self.centre.x dy = touch.location.y - self.centre.y # Draw path from centre point to touched point path = ui.Path() path.line_width = 4.0 path.move_to(-dx,dy) path.line_to(-dx,dy) path.move_to(0,0) path.line_to(dx,-dy) # Create line node from path line = ShapeNode() line.path = path line.position = (self.centre.x, self.centre.y) line.stroke_color = 'white' self.add_child(line) # Place dots at centre and touch points dotA = Dot(location = self.centre) self.add_child(dotA) dotB = Dot(location = touch.location) self.add_child(dotB) class Dot(ShapeNode): def __init__(self, *, location, **kwargs): circle = ui.Path.oval(0,0,20,20) super().__init__(circle, fill_color='white', **kwargs) self.position = (location.x, location.y) run(MyScene())
  • @SmartGoat, also, I toyed with creating a webview-backed UI framework with a Python API that should have been runnable on most platforms (search for ”youey” here), but of course it is a huge amount of work and has been more or less done before – but those other projects have been abandoned, and none of them worked on Pythonista anyway.

  • @cvp Thanks it worked perfectly! And yeah I realized @JonB, now i can adjust parameters since it works. Thank you both very much :)

  • @ccb_2k18 sorry to answer so late but there is a time zone difference😇
    I've seen you posted the same question in another topic and you are right.
    Don't ask a question to only one person, and surely me, there are in this forum a lot of marvelous people, and often a lot smarter than me.

  • Thanks for this information. Also read about online card generators by CardGenerator official program.

  • @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.


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

  • @JonB said:

    [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

    [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).


  • @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.


    Should work, depending on what you named things..

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

Internal error.

Oops! Looks like something went wrong!