-
ealdaz
Thanks, good pointer. I would not have figured it out in a million years.
However i think i must be missing something, from what i read in the doc:
Animation.completion A function (without parameters) that gets called when the animation completes.
However if i understand the example well the completion function that gets called is counterclockwise which has a parameter called completion?
def counterclockwise(completion=None):What am I missing? Is the parameter simply ignored?
Thx
-
ealdaz
I am having some success and enjoying using Animation on layers, however i am stuck on how to use Animation completion or Animation.finished
It would really help me if someone could add an example of the usage of both on the code below (example from the docs)
from scene import * import sys class MyScene (Scene): def setup(self): self.layer = Layer(Rect(self.size.w * 0.5 - 100, self.size.h * 0.5 - 100, 200, 200)) self.layer.background = Color(1, 0, 0) self.layer.animate('alpha', 0.0, duration=1.0, autoreverse=True, repeat=sys.maxint) def draw(self): background(0, 0, 0) self.layer.update(self.dt) self.layer.draw() run(MyScene())
From the docs:
Animation.completion A function (without parameters) that gets called when the animation completes. Animation.finished Gets set to True when the animation finishes.
Thanks for your help !
-
-
ealdaz
I have been experimenting with creating a Scene and adding a number of layers inside the scene and capturing the different touch events, this works great.
Now I would like to have a way of switching between two scenes when a user taps on the screen (each scene would ideally have a different layer layout and different touch actions).
I am keen to use SceneView so that i can also use buttons, etc. A started with a simple example to call my Scene that works well:
sv = SceneView() sv.scene = MyScene() sv.present('sheet')
I then tried to create a new class where i would overload the touch_ended function to switch to the other scene:
class MyView(SceneView): def __init__(self): self.scene = MyScene() def touch_ended(self,touch): self.scene = OtherScene()
But the python interpreter complains that the type 'scene SceneView' is not an acceptable base type...
I'm new to iOS and to this ui module, so i'm probably going about it the wrong way, any pointers very welcome
Thanks
Eduardo -
ealdaz
I've played around with it a bit and can't figure out how to switch between two Scenes, say for example as a result of a touch.
In other words if i've got two scenes and a scene viewer like in this simple example, what would be a possible/recommended way of switching from one to the other?
import scene, ui class MyScene1(scene.Scene): def draw(self): scene.background(0, 0, 0) scene.fill(0, 0, 1) for touch in self.touches.values(): scene.ellipse(touch.location.x - 50, touch.location.y - 50, 100, 100) class MyScene2(scene.Scene): def draw(self): scene.background(0, 0, 0) scene.fill(1, 0, 1) for touch in self.touches.values(): scene.rect(touch.location.x - 50, touch.location.y - 50, 100, 100) class SceneViewer(ui.View): def __init__(self, in_scene): self.present() self.scene_view = scene.SceneView(frame=self.bounds) self.scene_view.scene = in_scene self.add_subview(self.scene_view) def draw(self): ... Switching code to MyScene2 here? ..... def touch_ended(self,touch): ...Switching code to MyScene2 here?... SceneViewer(MyScene())
Thanks for your help !!
-
-
ealdaz
Hi JonB
Thanks for the info, sounds promising. Would you mind giving me a quick example (no functionality needed), on how you would create a custom view that would contain a sceneview? -
ealdaz
I would like to use my own images for an application, I have read in the "Using Pythonista" page (http://omz-software.com/pythonista/docs/ios/pythonista.html) that:
"If you use the scene or sound modules, you can use the + button at the top to insert images, sounds, colors and fonts."
I have not been able to figure out how to do this, all the posts I've found related to this are for older pythonista versions, so i'm left wondering if the + button technique is something applicable to older versions of pythonista only as I gather that some changes had to be made to comply with Apple's Store requirements...
Is there another way to add our own images so that pythonista scripts can access them by filename? With the photos module one can only access images by index, not name.
Thanks!
omz thanks for this great App, impressive work.
-
ealdaz
Got it, thanks for the super fast reply, very useful tip!!
Just to clarify for others, it's the copy/paste menu that appears when you're editing text and tap on the screen. The insert option doesn't always seem to appear, but i found that if i tap on an area of the window without text it does appear:
Select | Select All | Insert ...
Eduardo