我尝试使用vue模式(the one in the guide)确保平滑过渡。我的VueX store.js文件包含此突变:
swapModalView (state, view) {
state.modalView = 'none'
state.modalView = view
}
当视图设置为" none时,模态关闭,"并且当它发生任何其他事情时重新开启。
<VueModal v-if="modalView != 'none'"></VueModal>
这可能很简单,但我怎样才能将视图改为&#34; none,&#34;然后将其设置为转换结束后传递的视图?我想我可以在这里做,突变,对吗?
答案 0 :(得分:1)
我找到了。只是为css转换设置一个事件监听器,我从未在某处复制过某些代码。
import pygame
pygame.init()
screen = pygame.display.set_mode((1000, 480))
clock = pygame.time.Clock()
GREEN = (110, 190, 27)
BLUE = (0, 185, 225)
PLAYER_IMG = pygame.Surface((30, 45))
PLAYER_IMG.fill((250, 120, 0))
GRAVITY = 1
def game_loop():
x = 1
y = 340
x_change = 0
y_change = 0
on_ground = True
ground_height = 400
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x_change = -5
elif event.key == pygame.K_RIGHT:
x_change = 5
elif event.key == pygame.K_UP:
if on_ground:
# Set the y-velocity to a negative
# value to jump.
y_change = -20
on_ground = False
elif event.key == pygame.K_DOWN:
y_change = 5
elif event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT and x_change < 0:
x_change = 0
elif event.key == pygame.K_RIGHT and x_change > 0:
x_change = 0
# Adjust the y-velocity by adding the gravity each frame.
y_change += GRAVITY
# Move the player.
x += x_change
y += y_change
# Stop the player on the ground.
if y > ground_height:
# Stop the movement along the y-axis.
y_change = 0
y = ground_height
on_ground = True
screen.fill(BLUE)
pygame.draw.rect(screen, GREEN, [0, 445, 1000, 35])
screen.blit(PLAYER_IMG, (x, y))
pygame.display.update()
clock.tick(60)
game_loop()
pygame.quit()