Arcade学习笔记
可参考我写的简介 Arcade:适合少儿Python入门的游戏框架
游戏对象的组织#
- Window,窗口,展示窗口、管理事件
- View,视口,屏中屏,用来表示菜单、开场、正式游戏、结束等场次
- Scene,精灵场景,用来组织精灵的渲染
- SpriteList,精灵列表,用于批量绘制精灵
- Sprite
- TileMap
- Sprite...
- SpriteList,精灵列表,用于批量绘制精灵
- Camera,镜头,用来管理视口的可见性,如滚动屏幕、GUI重叠,以及抖动和推拉镜头
- Section,区域,用来管理事件
- Scene,精灵场景,用来组织精灵的渲染
- View,视口,屏中屏,用来表示菜单、开场、正式游戏、结束等场次
Window#
- run()
- activate()
- use() 把当前窗口的帧缓冲绑定到渲染命令
- switch_to() 转换窗口
- clear()
- close()
- center_window()
- dispatch_events()
- flip() 翻转缓冲区
- get_location()
- get_size()
- get_viewport()
- show_view(new_view: arcade.application.View)
- hide_view()
- maximize()
- minimize()
- update(delta_time: float)
- on_update(delta_time: float) # 主循环的更新事件钩子
- on_draw() # 主循环的绘制事件钩子
- on_resize(width: float, height: float) # 主循环的窗口缩放事件钩子
- on_key_...() # 主循环的键盘事件钩子
- on_mouse_...() # 主循环的鼠标事件钩子
- get_system_mouse_cursor(name)
- background_color
- ctx: arcade.context.ArcadeContext
- current_view: Optional[arcade.application.View]
- headless: bool
- set_caption(caption)
- set_exclusive_keyboard(exclusive=True)
- set_exclusive_mouse(exclusive=True)
- set_fullscreen()
- set_location(x, y)
- set_max_size(width: int, height: int)
- set_maximum_size(width, height)
- set_min_size(width: int, height: int)
- set_minimum_size(width: int, height: int)
- set_mouse_platform_visible(platform_visible=None)
- set_mouse_visible(visible: bool = True)
- set_size(width: int, height: int)
- set_update_rate(rate: float)
- set_viewport(left: float, right: float, bottom: float, top: float)
- set_visible(visible: bool = True)
- set_vsync(vsync: bool)
- test(frames: int = 10) 单元测试用
View#
- update(delta_time: float)
- on_draw()
- on_update(delta_time: float)
- on_show_view()
- on_hide_view()[source]
- on_resize(width: int, height: int)
- on_mouse_...()
- on_key_...()
- clear()
- add_section(section, at_index: Optional[int] = None)
- has_sections: bool
精灵#
- SpriteCircle
- AnimatedTimeBasedSprite
- AnimatedWalkingSprite
Sprite#
方法:
- kill()
- stop()
- draw(*, filter=None, pixelated=None, blend_function=None)
- update()
- update_animation(delta_time: float = 0.016666666666666666)
- on_update(delta_time: float = 0.016666666666666666)
- add_spatial_hashes()
- clear_spatial_hashes()
- collides_with_list(sprite_list: SpriteList) → list
- collides_with_point(point: Union[Tuple[float, float], List[float]]) → bool
- collides_with_sprite(other: arcade.sprite.Sprite) → bool
- draw_hit_box(color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]] = (0, 0, 0), line_thickness: float = 1)
- face_point(point: Union[Tuple[float, float], List[float]])
- forward(speed: float = 1.0)
- get_adjusted_hit_box() → Sequence[Union[Tuple[float, float], List[float]]]
- get_hit_box() → Sequence[Union[Tuple[float, float], List[float]]]
- pymunk_moved(physics_engine, dx, dy, d_angle)
- register_physics_engine(physics_engine)
- register_sprite_list(new_list: SpriteList)
- remove_from_sprite_lists()
- rescale_relative_to_point(point: Union[Tuple[float, float], List[float]], factor: float) → None
- reverse(speed: float = 1.0)
- set_hit_box(points: Sequence[Union[Tuple[float, float], List[float]]])
- set_position(center_x: float, center_y: float)
- set_texture(texture_no: int)
- append_texture(texture: arcade.texture.Texture)
- strafe(speed: float = 1.0)
- turn_left(theta: float = 90.0)
- turn_right(theta: float = 90.0)
属性:
- alpha: int
- angle: float
- bottom: float
- center_x: float
- center_y: float
- change_x: float
- change_y: float
- collision_radius: float
- color: Union[Tuple[int, int, int], List[int]]
- height: float
- left: float
- position: Union[Tuple[float, float], List[float]]
- properties: Dict[str, Any]
- pymunk: arcade.sprite.PyMunk
- radians: float
- right: float
- scale: float
- top: float
- visible: bool
- width: float