|
|
@@ -43,13 +43,15 @@
|
|
|
:style="playerStyle"
|
|
|
:class="{ 'collision': isColliding, 'success': hasReachedEnd }"
|
|
|
>
|
|
|
- <!-- 携带的物品 - 移动到玩家内部 -->
|
|
|
- <div
|
|
|
- v-for="(item, index) in gameState.player.carriedItems"
|
|
|
- :key="index"
|
|
|
- class="carried-item"
|
|
|
- :style="getCarriedItemStyle(index, item)"
|
|
|
- ></div>
|
|
|
+ </div>
|
|
|
+ <!-- 携带物品容器 - 默认隐藏,有物品时显示 -->
|
|
|
+ <div class="carried-items-container" v-show="gameState.player.carriedItems.length > 0">
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in gameState.player.carriedItems"
|
|
|
+ :key="index"
|
|
|
+ class="carried-item"
|
|
|
+ :style="getCarriedItemStyle(index, item)"
|
|
|
+ ></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -437,21 +439,14 @@ const playerStyle = computed(() => ({
|
|
|
// 计算携带物品样式
|
|
|
function getCarriedItemStyle(index, item) {
|
|
|
const baseSize = tileSize.value * CONFIG.STYLES.PLAYER_SIZE_RATIO * 0.3;
|
|
|
- const baseSize2 = tileSize.value * CONFIG.STYLES.PLAYER_SIZE_RATIO * 0.7;
|
|
|
- console.log(baseSize2, baseSize2 * index)
|
|
|
|
|
|
return {
|
|
|
- position: 'absolute',
|
|
|
+ position: 'relative',
|
|
|
width: baseSize + 'px',
|
|
|
height: baseSize + 'px',
|
|
|
backgroundSize: 'contain',
|
|
|
backgroundPosition: 'center',
|
|
|
backgroundRepeat: 'no-repeat',
|
|
|
- bottom: index * baseSize2 * 0.5 + 'px',
|
|
|
- left: baseSize2 + 'px', // 根据索引计算位置,从左到右排列
|
|
|
- transform: 'none',
|
|
|
- transformOrigin: 'center',
|
|
|
- zIndex: -1,
|
|
|
backgroundImage: `url(${item.img})`
|
|
|
};
|
|
|
}
|
|
|
@@ -1467,6 +1462,21 @@ onUnmounted(() => {
|
|
|
100% { transform: rotate(var(--player-rotation)) translateX(0) translateY(0); }
|
|
|
}
|
|
|
|
|
|
+/* 携带物品容器 */
|
|
|
+.carried-items-container {
|
|
|
+ position: absolute;
|
|
|
+ top: 20px;
|
|
|
+ left: 20px;
|
|
|
+ background: rgba(255, 255, 255, 0.8);
|
|
|
+ border: 2px solid #3498db;
|
|
|
+ border-radius: 10px;
|
|
|
+ padding: 10px;
|
|
|
+ display: flex;
|
|
|
+ gap: 10px;
|
|
|
+ z-index: 15;
|
|
|
+ backdrop-filter: blur(10px);
|
|
|
+}
|
|
|
+
|
|
|
/* 成功到达终点动画 */
|
|
|
.player.success {
|
|
|
animation: success 1s ease-in-out;
|