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.
Snake_catcher error: Type_error ‘Point’ object is not callable
-
Using the YouTube Snake Catcher Part 1 tutorial at the first run, where you should see snakes at the top of the screen I get Type_error ‘Point’ object is not callable on this line:
new_snake.position(random.randint(0,1024), 768)new_snake Is a is shown in the debugger as a _scene2.SprintNode object in the debugger.
What can I do to get past this?
The full code is here
from scene import * import sound import random import math A = Action class MyScene (Scene): def setup(self): self.frame_counter = 0 def did_change_size(self): pass def update(self): self.frame_counter = self.frame_counter + 1 if self.frame_counter >= 120: self.frame_counter = 0 new_snake = SpriteNode('emj:Snake') new_snake.position(random.randint(0,1024), 768) self.add_child(new_snake) 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)
-
Hello MATE!
this ones an easy one 😁
for
scene
module,Point
is a class that doesnt overide__call__
mqgic method. theposition
attribute for a Node is aPoint
object. so when you wrote:new_snake.position(random.randint(0,1024), 768)
your calling on position lime it was a function.
what you shouldmofmdone is set the attribute instead of calling it.
new_snake.position = Point(random.randint(0,1024), 768)
here we are calling he
__init__
methodm instead of the__call__
to create a newPoint
object. -
Also remember to use
```
before and after blocks of code to format them properly. Thanks! -
Thanks @stephen. I hate it when I make an easy mistake :-).