im runing iPadOS 13.4 and i also cannot set the widget from settings. but i have no problem setting the widget using appex.set_widget_view()
.
i hope this helps you out until the bug is corrected!
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
im runing iPadOS 13.4 and i also cannot set the widget from settings. but i have no problem setting the widget using appex.set_widget_view()
.
i hope this helps you out until the bug is corrected!
Here is a little game to help new develpoers to game design get started. there is a tutorial in exmples but its very minimal and doesnt give examples of diferent styles of writing. this currently is not a tutorial. and it is not flooded with comments so that its easier to follow the code. any questions are more than welcomeand i will add annotations as needed.
the game itssrlf is not perfect and does have bugs that pop up here and there. this is mainly due to using multiple styles at once creating small conflicts but the game does play and should be easy to expand nd add aditional components. i tried to leave it in a way that made it to whoever was using it could add functionality to help learn and understand game development. all images are builtin and script should run without any dependancies as long as its ran within Pythonista.
Enjoy
Stephen, Frey
@Karina @Drizzel here is a demo for action timing. i intended to have much more informative and visually attractive version and ill improve it in time but for noe you can see a visual difference between each interpolation.
note: this is formated for ipad only. future versions will have formatting for other devices. i appoligise.
from scene import *
class BaseSign(SpriteNode):
def __init__(self, texture=None, tag='Sign', *args, **kwargs):
super().__init__(texture=texture, *args, **kwargs)
self.anchor_point=(0.0, 1.0)
self.position = Point(10, get_screen_size()[1]-10)
self.z_position=1
self.color='#000000'
self.size=Size(get_screen_size()[0]-20, get_screen_size()[1]-20)
self.bg=SpriteNode(
texture=None,
color='#80cdff',
position=Point(3, -3),
anchor_point=(0.0, 1.0),
size=Size(get_screen_size()[0]-26, get_screen_size()[1]-26),
parent=self)
self.sign=LabelNode(
'',
position=Point(1, 15),
z_position=3,
font=('Ubuntu Mono', 18),
parent=self.bg,
color='#000000',
anchor_point=(0.0, 1.0))
class MyScene (Scene):
def setup(self):
self.dur=5
self.moveToPos=(73, 245)
self.sign=BaseSign(parent=self, position=self.size/2)
self.sign.sign.text=self.Text()
for x in range(16):
b=SpriteNode(Texture('pzl:BallGray'),
size=Size(16, 16),
color='#00f90b',
position=Point(73, (get_screen_size()[1]-132) - 36.15*x),
z_position=9,
parent=self)
b.run_action(
Action.repeat(
Action.sequence(
Action.call(self.UpdateTime, 0.1),
Action.wait(0.5),
Action.move_to(self.moveToPos[1], b.position[1], 2, x),
Action.move_to(self.moveToPos[0], b.position[1], 2, x)),-1))
def UpdateTime(self, node, progress):
if self.speed is 1:
self.speed=0.5
else:
self.speed=1
self.sign.sign.text=self.Text()
def Text(self):
return f'''
╔════════════════════════╗
║ BUILT_IN_CONSTANT ║
╠════╦════════╦══════════╣
║ 2s ║ 2 part ║ 1x speed ║
╠════╩════════╩══════════╣
║TIMING_LINEAR ║
╟═╡ ╞═╢
║TIMING_EASE_IN_2 ║
╟═╡ ╞═╢
║TIMING_EASE_IN_2 ║
╟═╡ ╞═╢
║TIMING_EASE_OUT ║
╟═╡ ╞═╢
║TIMING_EASE_OUT_2 ║
╟═╡ ╞═╢
║TIMING_EASE_IN_OUT ║
╟═╡ ╞═╢
║TIMING_SINODIAL ║
╟═╡ ╞═╢
║TIMING_ELASTIC_OUT ║
╟═╡ ╞═╢
║TIMING_ELASTIC_IN ║
╟═╡ ╞═╢
║TIMING_ELASTIC_IN_OUT ║
╟═╡ ╞═╢
║TIMING_BOUNCE_OUT ║
╟═╡ ╞═╢
║TIMING_BOUNCE_IN ║
╟═╡ ╞═╢
║TIMING_BOUNCE_IN_OUT ║
╟═╡ ╞═╢
║TIMING_EASE_BACK_IN ║
╟═╡ ╞═╢
║TIMING_EASE_BACK_OUT ║
╟═╡ ╞═╢
║TIMING_EASE_BACK_IN_OUT ║
╟═╡ ╞═╢
╚════════════════════════╝'''
if __name__ == '__main__':
run(MyScene(), show_fps=True)
@rownn i annotated with comments.
class MyTextView(ui.TextView):
def __init__(self, *args, **kwargs):
self.delegate = self
def begin_editing(self):
# forces keyboard to present
pass
def end_editing(self):
# forces keyboard to close
pass
def replace_range(self, range, text):
pass
### start of delegate methods ###
def TextView_should_begin_editing(self, textview):
# resize and reposition for keyboard
return True
def TextView_did_begin_editing(self, textview):
# keyboard presented
pass
def TextView_did_end_editing(self, textview):
pass
def TextView_should_return(self, textview):
# resize and reposition for no keyboard
textfield.end_editing()
# keyboard not presented
return True
def TextView_should_change(self, textview, range, replacement):
return True
def TextView_did_change(self, textview):
pass
heres is example of using brush like objects with scrolling nd random (not too random) spacing. if you have ny questions please ask!
@Drizzel thank you, i alwys try to help out tht way i get to learn kong the wy aswell 😎🤓🤓
from scene import *
import sound
import random
import math
A = Action
def w(): return get_screen_size()[0]
def h(): return get_screen_size()[1]
def MaxBrushSize(): return 10-2
def BaseBlock(parent):
return SpriteNode(Texture('plf:Tile_BoxItem_boxed'),
size=Size(64, 64), parent=parent,
anchor_point=(0.0, 0.0))
def Block(parent):
return SpriteNode(Texture('plf:Tile_BoxCrate_double'),
size=Size(64, 64), parent=parent,
anchor_point=(0.0, 0.0))
def Stone(parent, x):
return SpriteNode(Texture('plf:Tile_BrickGrey'),
size=Size(64, 64), parent=parent,
anchor_point=(0.0, 0.0), position=Point(x*64, 0))
class TopBrush(Node):
def __init__(self, brushSize, *args, **kwargs):
self.base=BaseBlock(self)
self.size=Size(64, 64)
self.position=Point(w()+(self.size.w), h()-self.size.h)
self.brushSize=brushSize
self.blocks=list([self.base, ])
for x in range(1, self.brushSize):
b=Block(self)
b.position=(self.base.position[0], self.base.position[1] - x*b.size[1])
self.blocks.append(b)
class BottomBrush(Node):
def __init__(self, brushSize, *args, **kwargs):
self.base=BaseBlock(self)
self.size=Size(64, 64)
self.position=Point(w()+(self.size.w), 0)
self.brushSize=brushSize
self.blocks=list([self.base, ])
for x in range(1, self.brushSize):
b=Block(self)
b.position=(self.base.position[0], self.base.position[1] + x*b.size[1])
self.blocks.append(b)
class MyScene (Scene):
def setup(self):
self.background=SpriteNode(Texture('plf:BG_Colored_grass'),
size=Size(w(), h()), position=self.size/2, parent=self)
self.preset=[(1, 7),(2, 6),(3, 5),(4, 4),(5, 3),(6, 2),(7, 1)]
self.i=0.0
self.brushSpawnTimer=3.0
self.brushes=list([])
self.scrollSpeed=40
for x in range(int((w()*128)/64)):
self.brushes.append(Stone(self, x))
def Add_Brush(self, choice):
if self.i > self.brushSpawnTimer:
bb=BottomBrush(choice[0])
tb=TopBrush(choice[1])
self.add_child(bb)
self.add_child(tb)
self.brushes.append(bb)
self.brushes.append(tb)
self.i=0.0
self.brushSpawnTimer = random.randrange(3, 6)
else:
sb=Stone(self, (w()+128)/64)
self.brushes.append(sb)
def Remove_Brush(self, brush):
self.brushes.remove(brush)
brush.remove_from_parent()
self.Add_Brush(random.choice(self.preset))
def did_change_size(self):
pass
def Scroll(self, brush):
x=brush.position[0]-self.scrollSpeed*self.dt
y=brush.position[1]
return Point(x, y)
def update(self):
self.i += self.dt
for brush in self.brushes:
if brush.position[0] <= -64:
self.Remove_Brush(brush)
brush.position = self.Scroll(brush)
def touch_began(self, touch):
pass
def touch_moved(self, touch):
pass
def touch_ended(self, touch):
pass
if __name__ == '__main__':
run(MyScene(), show_fps=False)
.txt
files.⏎
button to send user back to menu without having to reload Script.Scripts ↴
Scripts.txt
. on the first available empty line and paste unicode.:
script name:ABCDEFG...
Emoji and Symbold ↴
💪 ⟾ Emoji.txt
and ♳✯✟ ⟾ Misc.txt
place eachPremade Smilies ↴
Faces.txt
place each face on a single line.For seamless Use, change Script file name to Special Characters.py
and
place inside Examples/Keyboard/
replacing original script. This way will use
new Version instead without the need to Setup inside Pythonista settings.
.txt
filesfile name
inside Options.txt
—STEPHEN FREY
Included are two files for offline Resource for Unicode. Files are to large to open inside Pythonists and Editorial.
Attribution goes to OMZ, devloper of Pythonista
for providing IDE as well as the tools and original script for this Module!
Files located at github
pythonista Docs
def layout(self):
# This will be called when a view is resized. You should typically set the
# frames of the view's subviews here, if your layout requirements cannot
# be fulfilled with the standard auto-resizing (flex) attribute.
pass
often used to signal when screen orientation has changed.
also in scene
Module
def did_change_size(self):
pass
After many hours of thought and going over my cose a few times i fiund that since
I already released the Game Example Space Escape, its nearly pointless to do
a tutorial series on the same project.. That said i will be closing this one here
and i will create a new one.
Python RPG will cover at more aspects of game development.
and much more..
This new series will be done in sections due to the amount of code and testing we will
need. i will provide sprite sheets to help follow along, though i do encourage using your
own assets to help motivate yourself to push on. game development can get pretty stressfull
and even make you feel like its too hard. but keep pushing along and ALWAYS ask a question
if you have one!
Keep note that i will be writing this on my own and do have a life outside Python, at least i
like to think i do... so there might be gaps in time between sections and chapters. 🤓
@jackattack said:
Also the only bit I didn’t really understand was when you set up the button class you used init, but then you did spritenode.init what is this for?
when you subclass an object that has __init__
paramiters you must either call the Parent class __init__
as i did here or you can use super()
. if you do not call the parent's __init__
then the new object will not inherit the dirived.
@jackattack said:
I’ve learnt so much reading your code, love the way you’ve done so many things, spent ages going through it all. Could you give me any insight into the order you went about writing it?
I usually start with utility classes. in my Example game this would be stuff like Screen()
and EventManager()
, then visual testing. at this point i woud start my ButtonNode()
and Animations()
.. now i create my Player()
, GUI()
and o on. the order on the script itself doesnt matter with Object Orientated Programing (OOP) just remember the Interpreter exec the scripts top down. so in order to Dirive from from Class A it must exist before Class B.
@jackattack said:
Wow this works perfectly thank you so much, I’m going to take some time to study it and try to learn how to recreate it with some other effects. Thanks for taking the time out 😌
Not a problem at all! 🥂💯 i enjoy helping others if you have any equestions please dont hesitate!;
You can use editor
module to get selected text range and then split the lines into a list. last you should be able to iterate the list and use exec
to run each line. Alterativly you could create a temp script at run time then write the selected code to that script then run the scriot. just make ure to save the stream and close it.
if you need an example i can write one up for you but this should get you in the right direction.
After many hours of thought and going over my cose a few times i fiund that since
I already released the Game Example Space Escape, its nearly pointless to do
a tutorial series on the same project.. That said i will be closing this one here
and i will create a new one.
Python RPG will cover at more aspects of game development.
and much more..
This new series will be done in sections due to the amount of code and testing we will
need. i will provide sprite sheets to help follow along, though i do encourage using your
own assets to help motivate yourself to push on. game development can get pretty stressfull
and even make you feel like its too hard. but keep pushing along and ALWAYS ask a question
if you have one!
Keep note that i will be writing this on my own and do have a life outside Python, at least i
like to think i do... so there might be gaps in time between sections and chapters. 🤓
@jackattack said:
Also the only bit I didn’t really understand was when you set up the button class you used init, but then you did spritenode.init what is this for?
when you subclass an object that has __init__
paramiters you must either call the Parent class __init__
as i did here or you can use super()
. if you do not call the parent's __init__
then the new object will not inherit the dirived.
@jackattack said:
I’ve learnt so much reading your code, love the way you’ve done so many things, spent ages going through it all. Could you give me any insight into the order you went about writing it?
I usually start with utility classes. in my Example game this would be stuff like Screen()
and EventManager()
, then visual testing. at this point i woud start my ButtonNode()
and Animations()
.. now i create my Player()
, GUI()
and o on. the order on the script itself doesnt matter with Object Orientated Programing (OOP) just remember the Interpreter exec the scripts top down. so in order to Dirive from from Class A it must exist before Class B.
@jackattack said:
Wow this works perfectly thank you so much, I’m going to take some time to study it and try to learn how to recreate it with some other effects. Thanks for taking the time out 😌
Not a problem at all! 🥂💯 i enjoy helping others if you have any equestions please dont hesitate!;
here is my script example. sorry it took a while lol. its not very clean but i think it should be easy to follow. let me know if you have any questions. you should benable to use thenSprite class to create other objects and as you will see this approach doesnt use the update method at all or depend on position.
from scene import *
from time import sleep
import sound
import random
import math
A = Action
Character_Male='IMG_3039.jpg'
def get_texture(sheet, x, y, w, h):
'''
for cleaner Code
'''
return Texture(sheet).subtexture(Rect(x, y, w, h))
class Direction:
'''
simple Constants
'''
NORTH="north"
SOUTH="south"
EAST="east"
WEST="west"
class Sprite(SpriteNode):
'''
Use this class for game objects
'''
def __init__(self,sprite_sheet, *args, **kwargs):
self.sprite_sheet=sprite_sheet
self.animations=dict(
{"idle":get_texture(self.sprite_sheet, 0.00, 0.75, 0.33, 0.25)})
SpriteNode.__init__(self, texture=self.animations["idle"], *args, **kwargs)
self.movement_speed=50
self.active_direction=Direction.SOUTH
self.Texture_Group(
"move-north",
[
get_texture(self.sprite_sheet, 0.00, 0.75, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.33, 0.75, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.66, 0.75, 0.33, 0.25)
])
self.Texture_Group(
"move-south",
[
get_texture(self.sprite_sheet, 0.00, 0.50, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.33, 0.50, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.66, 0.50, 0.33, 0.25)
])
self.Texture_Group(
"move-east",
[
get_texture(self.sprite_sheet, 0.00, 0.25, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.33, 0.25, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.66, 0.25, 0.33, 0.25)
])
self.Texture_Group(
"move-west",
[
get_texture(self.sprite_sheet, 0.00, 0.00, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.33, 0.00, 0.33, 0.25),
get_texture(self.sprite_sheet, 0.66, 0.00, 0.33, 0.25)
])
# decorator alows the use of time.sleep() without blocking
@ui.in_background
def Run_Animation(self, tag):
for x in self.animations[f"{tag}-{self.active_direction}"]:
self.texture = x
sleep(0.2)
self.texture=self.animations[f"{tag}-{self.active_direction}"][0]
def Texture_Group(self, tag, texture_list):
self.animations[tag]=texture_list
def Change_Direction(self, direction):
self.active_direction=direction
if direction == Direction.SOUTH:
self.velocity=(0.0, -self.movement_speed)
elif direction == Direction.NORTH:
self.velocity=(0.0, self.movement_speed)
elif direction == Direction.EAST:
self.velocity=(-self.movement_speed, 0.0)
elif direction == Direction.WEST:
self.velocity=(self.movement_speed, 0.0)
class Button(SpriteNode):
'''
Simple Button Object
'''
def __init__(self, text, meta, action=None, *args, **kwargs):
SpriteNode.__init__(self, Texture('pzl:Gray7'), *args, **kwargs)
self.texture=Texture('pzl:Gray7')
self.action=action
self.text=LabelNode(text, anchor_point=(0.5, 0.5), color="yellow", parent=self)
self.meta=meta
# Not used in this example but can be lol
def Pressed(self):
self.action(self)
class MyScene (Scene):
def setup(self):
self.screen="game"
self.background_color='black'
self.buttons=[]
self.player=Sprite(Character_Male, position=self.size/2, scale=4, parent=self)
self.n = -1
self.up_button=Button(
"↑",
Direction.NORTH,
position=Point(get_screen_size()[0]/4*3, 270),
scale=2,
parent=self)
self.buttons.append(self.up_button)
self.down_button=Button(
"↓",
Direction.SOUTH,
position=Point(get_screen_size()[0]/4*3, 130),
scale=2,
parent=self)
self.buttons.append(self.down_button)
self.right_button=Button(
"→",
Direction.WEST,
position=Point(get_screen_size()[0]/4*3+70, 200),
scale=2,
parent=self)
self.buttons.append(self.right_button)
self.left_button=Button(
"←",
Direction.EAST,
position=Point(get_screen_size()[0]/4*3-70, 200),
scale=2,
parent=self)
self.buttons.append(self.left_button)
def touch_began(self, touch):
for btn in self.buttons:
if touch.location in btn.bbox:
self.player.Change_Direction(btn.meta)
self.player.run_action(
Action.move_by(
self.player.velocity[0],
self.player.velocity[1]))
self.player.Run_Animation("move")
def touch_ended(self, touch):
pass
if __name__ == '__main__':
run(MyScene(), show_fps=True)
If your running an example script chances are it is executing and doing some function but has no visual presentation and exec in less then a second. if you use scene
, ui
, while
or for loop
you can maintain the program and using scene
and/or ui
modules to present visual presence.
post your code and that will help us help you. use MarkDown to format the code. before and after place ```
@jackattack said:
Sure can do, what format can I post it on here?
You will have to upload somewhere then hyperlink it. I personally use Imgur
@jackattack said:
I basically just cropped one from online to make it easier to work with
no problem its just to help replicate the same execution you have 😎
@jackattack
Any chance we can get the sprite sheet your using?
Also can you post the code you are using just in case it's just a small mishap? Make sure to put the code inside two ```
so that it is formatted properly
Checkout the *** COMPOSE *** on top right when your writing a post 😀
Hey buddy! I have a "full" example game for new developers to take a look at here on the forums. He game doesn't use sprite sheets but it should give you a good understanding of the animation system 😀
While you look this over I will prepare an example for your specific use and give some comment explanation of what's going on! I got 4 kiddos so just bare with me lol I'm not as fast as I used to be buddy!
Here Is the post for the example Game 😉