Welcome to the Pythonista Community Forums!

Pythonista is a Python programming environment for iOS. To learn more, head over to the Pythonista Website.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter
equivalent Codea features in Pythonista
  • Hi

    I have been using Codea for a while. I have recently downloaded Pythonista and I am trying to work with it. But since I am familiar with Codea I have two questions:

    1. How in Pythonista can I change Scenes? You know, I want a Scene showing first and then I want another one showing after some operations.

    In Codea we have the Main routine, and you can built your main operations in its Draw(), and refer to various scenes in that.

    But in all Pythonista examples there was just one Scene and I couldn't find an equivalent for Draw() of the Main routine in Lua. This is a crucial feature. Because what I want is a root routine which includes some operations and calls various Scenes.


    2. in Codea there are Sprites and Meshs. As iPad process meshes much faster than sprites, people use meshes. Do we have these concepts in Pythonista?


    It has to be told that I don't want to compare these two great apps, I am just familiar with Codea and I want to understand its equivalent features in Pythonista

    Thank you
  • any answers for a solution for #1? I've actually built all my scenes but due to problem #1 i don't know how to relate them. help plz!
  • There isn't really any built-in support for running multiple scenes in Pythonista. However, you could define one "master" scene that then forwards events to an "active" scene (that could be changed while the master scene is running). I've made a simple example that uses this approach here:
    https://gist.github.com/4059061
  • thank you so much. i will check that example and i guess it would be fine.
  • i tried to the scheme u propopsed with the "scene with layers" (Myscene) as the slave layer and a master scene (Myscene1).
    unfortunately when i run Myscene1 it tells me, as the first error, that (Myscene object had no attribute "bounds"). so i guess when the slave scenes do have layers it is tricky. what do u suggest? defining all the slave scenes to work and modify just layers in the master scene?
  • i just realized that probably i can use another approach without multiscenes. i can built draw1(),...,drawN() and call each of them i want in draw() of a single scene. i try to see what would happen this way.

    ...it seems to work. so i can now use multi pages. so i guess #1 is solved for me.
  • I was also looking for ways of using scenes for different game states. I'm a total python noob, more used to c++, so not sure if I'm making things harder than they need to be. Anyway, extended the script on gist and reshaped it a little... This might be more like the solution that NoneNone was looking for (and shows how to copy size or other attributes from main scene, guess it'll work for bounds too).

    If Im doing anything really backward or silly here, appreciate comments :)

    https://gist.github.com/4479444
  • I was considering this problem as well and I think I have a solution.

    Ok my plan with this is to have my elements of my game designed as a 'level file'. This file would contain arrays of data information on which objects of which type are spawning where. I will do this with a massive array containing a bunch of ([x,y],[width,height],typeObject) structures. Then my scene will have a 'level' variable built into it, something I can increase each time the goal is met.

    So it would call like:

    if self.level==1: loadLevel(self,level1,extraStuff)
    elif self.level==2: loadLevel(self,level2,extraStuff)
    else: loadLevel(self,level3,extraStuff)

    Where essentially the loadLevel function would get all the info for objects in each level using pre-coded information. It would also modify "self" so that all the information in "self" is consistent with the new level.. Effectively making a new scene.

    After you load your level, you would then perform collision tests etc and continue with the process.

    idk I am still working on an idea for this because I want to design my own game on iPad and it seems as designers, we will have to create our own scenes and ways of handling them.