Skip to content

Commit 806daeb

Browse files
Fix app crashes when touching bomb by passing correct type to camera.shake() (#1928)
TLDR; * App crashes when touching a bomb with error. * `AttributeError: 'tuple' object has no attribute 'x'` * Made the following changes * added `from pyglet.math import Vec2` to the top of the file * passed `Vec2` to `camera.shake()` instead of tuple * old line: `camera.shake((4, 7))` * new line: `camera.shake(Vec2(4, 7))` I initially thought this was intended behavior but I realized the app was actually just crashing. The offending line was calling `camera.shake()` which according to it's definition in `./venv/lib/python3.11/site-packages/arcade/camera.py` expects a `Vec2` as it's argument which is being imported in that file with `from pyglet.math import Mat4, Vec2, Vec3` but the call to `camera.shake` was getting a `tuple` hence the `AttributeError`.
1 parent d872405 commit 806daeb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arcade/examples/camera_platform.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import time
1212

13+
from pyglet.math import Vec2
14+
1315
import arcade
1416

1517
TILE_SCALING = 0.5
@@ -254,7 +256,7 @@ def on_update(self, delta_time):
254256
for bomb in bombs_hit:
255257
bomb.remove_from_sprite_lists()
256258
print("Pow")
257-
self.camera.shake((4, 7))
259+
self.camera.shake(Vec2(4, 7))
258260

259261
# Pan to the user
260262
self.pan_camera_to_user(panning_fraction=0.12)

0 commit comments

Comments
 (0)