我正在尝试使用有多个级别的livewires创建游戏.在每个级别,屏幕将需要不同的大小,所以我可以创建一个新的屏幕,或者我可以调整它的大小.当我尝试新屏幕时,像这样(mcve):
from livewires import games
games.init(screen_width = 500, screen_height=100, fps = 50)
#dosomething
games.screen.quit()
games.init(screen_width = 100, screen_height=500, fps = 50)
games.screen.mainloop()
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Traceback (most recent call last):
File "C:\Users\Fred\Desktop\game\main.py", line 6, in <module>
games.screen.mainloop()
File "C:\Users\Fred\Desktop\game\livewires\games.py", line 308, in mainloop
object._tick()
File "C:\Users\Fred\Desktop\game\livewires\games.py", line 503, in _tick
self.tick()
File "C:\Users\Fred\Desktop\game\livewires\games.py", line 776, in tick
self._after_death()
File "C:\Users\Fred\Desktop\game\main.py", line 5, in <module>
games.init(screen_width = 100, screen_height=500, fps = 50)
File "C:\Users\Fred\Desktop\game\livewires\games.py", line 884, in init
screen = Screen(screen_width, screen_height, fps) …Run Code Online (Sandbox Code Playgroud) 我一直在使用 Python 3.3.1 从 Python for Absolute Beginners 一书中编程。
我正在尝试使用以下代码向屏幕添加文本。我需要继续使用 Python 3.3.1,但我认为书中的代码适用于 Python 2.X。
from livewires import games, color
class Pizza(games.Sprite):
"""A falling pizza"""
def __init__(self, screen, x,y, image, dx, dy):
"""Initialise pizza object"""
self.init_sprite(screen = screen, x = x, y = y, image = image, dx = dx, dy = dy)
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
#main
my_screen = games.Screen(SCREEN_WIDTH, SCREEN_HEIGHT)
wall_image = games.load_image("wall.jpg", transparent = False)
pizza_image = games.load_image("pizza.jpg")
my_screen.set_background(wall_image)
games.Text(screen = my_screen, x = 500, y …Run Code Online (Sandbox Code Playgroud) 我想知道在 python 中是否有一种方法,当我的 games.screen.mainloop() 内的图形部分正在运行时,我是否可以执行诸如从控制台通过 raw_input() 获取用户输入之类的操作。
有 3 个 Livewire 组件UserIsExpired,每个组件分别有 3 个按钮UserIsActive。UserIsPending单击按钮时,它应该用其各自的组件替换先前的组件。
<button wire:click="$emit(active)">{{ __('Active') }}</button>
<button wire:click="$emit(pending)">{{ __('Pending') }}</button>
<button wire:click="$emit(expired)">{{ __('Expired') }}</button>
Run Code Online (Sandbox Code Playgroud)
视野中
<livewire:user-is-active :active="$active"/>
<livewire:user-is-pending :pending="$pending"/>
<livewire:user-is-expired :expired="$expired"/>
Run Code Online (Sandbox Code Playgroud)
组件示例
class UserIsExpired extends Component
{
protected $listeners = ['expired'];
public function render()
{
return <<<'blade'
<div>
{{-- The best athlete wants his opponent at his best. --}}
</div>
blade;
}
}
Run Code Online (Sandbox Code Playgroud)
Active单击按钮时,它应该加载UserIsActive组件。其他两个也是如此。
我一直在寻找 livewire 文档,但无法找到如何实现它。提前致谢。
我在安装 livewire 3 软件包时遇到一些问题,我收到以下信息:
问题1
根composer.json需要livewire/livewire 3.0@beta,发现livewire/livewire[dev-throw-error-when-testing-non-livewire-class, ..., dev-bad-hotfix-test, v0.0.1 , ..., v0.7.4, v1.0.0, ..., 1.x-dev, v2.0.0, ..., 2.x-dev, v3.0.0-beta.1, v3.0.0-beta .2, v3.0.0-beta.3] 但它与约束不匹配。
安装失败,将 ./composer.json 和 ./composer.lock 恢复为其原始内容
像网站文档一样安装Livewire 3。
我正在学习《面向绝对初学者的 Python 编程》这本书,并决定通过制作自己的游戏来测试我的一些技能。游戏基本上是“不要被飞来的尖刺击中”,我遇到了一个问题。使用此代码运行时:
class Player(games.Sprite):
"""The player that must dodge the spikes."""
def update(self):
"""Move to the mouse."""
self.x = games.mouse.x
self.y = games.mouse.y
self.check_collide()
def check_collide(self):
"""Check for a collision with the spikes."""
for spike in self.overlapping_sprites:
spike.handle_collide()
def main():
pig_image = games.load_image("Mr_Pig.png")
the_pig = Player(image = pig_image,
x = games.mouse.x,
y = games.mouse.y)
games.screen.add(the_pig)
games.mouse.is_visible = False
games.screen.event_grab = True
games.screen.mainloop()
main()
Run Code Online (Sandbox Code Playgroud)
我没问题。但是当我想使用“ init ”时,就像在这段代码中一样:
class Player(games.Sprite):
"""The player that must dodge the spikes."""
def update(self):
"""Move to …Run Code Online (Sandbox Code Playgroud) 我使用 Laravel 8。
我在RouteServiceProvider以下位置定义了受保护的命名空间:
protected $namespace = 'App\Http\Controllers';
Run Code Online (Sandbox Code Playgroud)
然后通过以下路线使用 livewire:
Route::get('/xxx' , App\Http\Livewire\Counter::class);
Run Code Online (Sandbox Code Playgroud)
但我有以下错误:
Invalid route action: [App\Http\Controllers\App\Http\Livewire\Counter].
Run Code Online (Sandbox Code Playgroud)
注意:这增加App\Http\Controllers了我的第一个动作!!!如果protected $namespace全部删除就可以了。但我不想删除它。
有没有办法让我同时拥有两者?controller protected namespace(用于控制器命名空间)和一个Route::getfor Full-Page Components?
我有一个向导表单,它是一个 livewire 组件,它总是在我打字时重新呈现。我想停止重新渲染,直到我提交表单。
谁能帮帮我?抱歉英语不好,我是法国人。
它仍然是一个不完整的程序,但由于某种原因文本框的价值不会增加它应该...为什么这?当比萨饼精灵与潘精灵重叠时,文本框中的分数应该增加10倍.为什么不会出现这种情况?
谢谢!
'''
Created on Jul 1, 2011
@author: ******* Louis
'''
#Watch me do.
from livewires import games, color
import random
games.init (screen_width = 640, screen_height = 480, fps = 50)
#Pizza Class
class Pizza (games.Sprite):
pizzaimage = games.load_image ("pizza.bmp", transparent = True)
def __init__(self, x = random.randrange(640), y = 90, dy = 4):
super (Pizza, self).__init__(x = x,
y = y,
image = Pizza.pizzaimage,
dy = dy)
def handle_caught (self):
self.destroy()
class Pan (games.Sprite):
panimage = games.load_image ("pan.bmp", …Run Code Online (Sandbox Code Playgroud)