【unity實戰】使用舊輸入系統Input Manager 寫一個 2D 平臺游戲玩家控制器——包括移動、跳躍、滑墻、蹬墻跳

最終效果

在這里插入圖片描述

文章目錄

  • 最終效果
  • 素材下載
    • 人物
    • 環境
  • 簡單繪制環境
  • 角色移動跳躍
  • 視差和攝像機跟隨效果
  • 奔跑動畫切換
  • 跳躍動畫,跳躍次數限制
  • 角色添加2d物理材質,防止角色粘在墻上
  • 如果角色移動時背景出現黑線條
    • 方法一
    • 方法二
  • 墻壁滑行
  • 實現角色滑墻不可以通過移動離開且不可翻轉角色
  • 空中運動控制
  • 可變跳躍高度
  • 蹬墻跳
  • 完整代碼
  • 源碼
  • 完結

素材下載

人物

https://rvros.itch.io/animated-pixel-hero
在這里插入圖片描述

環境

https://bardent.itch.io/the-bardent-asset-pack
在這里插入圖片描述
https://brullov.itch.io/oak-woods
在這里插入圖片描述

簡單繪制環境

參考:【推薦100個unity插件之14】Unity2D TileMap的探究(最簡單,最全面的TileMap使用介紹)
在這里插入圖片描述

角色移動跳躍

新增PlayerController

public class PlayerController : MonoBehaviour
{private float movementInputDirection; // 水平輸入方向private bool isFacingRight = true; // 玩家是否面向右側private Rigidbody2D rb;public float movementSpeed = 10.0f; // 移動速度public float jumpForce = 16.0f; // 跳躍力度void Start(){rb = GetComponent<Rigidbody2D>();}void Update(){CheckInput(); // 檢查輸入CheckMovementDirection();}private void FixedUpdate(){ApplyMovement(); // 應用移動}// 檢查玩家面朝的方向private void CheckMovementDirection(){if (isFacingRight && movementInputDirection < 0){Flip(); // 翻轉角色}else if (!isFacingRight && movementInputDirection > 0){Flip(); // 翻轉角色}}// 檢查輸入private void CheckInput(){movementInputDirection = Input.GetAxisRaw("Horizontal"); // 獲取水平輸入if (Input.GetButtonDown("Jump")){Jump(); // 如果按下跳躍鍵,則執行跳躍}}// 跳躍private void Jump(){rb.velocity = new Vector2(rb.velocity.x, jumpForce); // 設置 y 方向的速度為跳躍力度}// 移動private void ApplyMovement(){rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 設置 x 方向的速度}// 翻轉角色private void Flip(){isFacingRight = !isFacingRight; // 改變面向方向的標志transform.Rotate(0.0f, 180.0f, 0.0f); // 旋轉角色}
}

配置
在這里插入圖片描述
效果
在這里插入圖片描述

視差和攝像機跟隨效果

參考:【unity小技巧】Unity實現視差效果與無限地圖

新增CameraController代碼

public class CameraController : MonoBehaviour
{public Transform target;//玩家的位置public Transform farBackground, middleBackground, frontBackground;//遠的背景和中間背景的位置private Vector2 lastPos;//最后一次的相機位置void Start(){lastPos = transform.position;//記錄相機的初始位置}void Update(){//將相機的位置設置為玩家的位置,但限制在一定的垂直范圍內//transform.position = new Vector3(target.position.x, target.position.y + 1f, transform.position.z);//計算相機在上一幀和當前幀之間移動的距離Vector2 amountToMove = new Vector2(transform.position.x - lastPos.x, transform.position.y - lastPos.y);//根據相機移動的距離,移動遠背景和中間背景的位置farBackground.position += new Vector3(amountToMove.x, amountToMove.y, 0f);middleBackground.position += new Vector3(amountToMove.x * 0.9f, amountToMove.y, 0f);frontBackground.position += new Vector3(amountToMove.x * 0.5f, amountToMove.y, 0f);lastPos = transform.position;//更新最后一次的相機位置}
}

Map代碼

public class Map : MonoBehaviour
{[Header("無限地圖")]private GameObject mainCamera;//主攝像機對象private float mapwidth;//地圖寬度private float totalwidth;//總地圖寬度public int mapNums;//地圖重復的次數void Start(){mainCamera = GameObject.FindGameObjectWithTag("MainCamera");//查找標簽為"MainCamera'"的對象并賦值mapwidth = GetComponent<SpriteRenderer>().sprite.bounds.size.x;//通過SpriteRenderer獲得圖像寬度totalwidth = mapwidth * mapNums;//計算總地圖寬度}void FixedUpdate(){Vector3 tempPosition = transform.position;//獲取當前位置if (mainCamera.transform.position.x > transform.position.x + totalwidth / 2){tempPosition.x += totalwidth;//將地圖向右平移一個完整的地圖寬度transform.position = tempPosition;//更新位置}else if (mainCamera.transform.position.x < transform.position.x - totalwidth / 2){tempPosition.x -= totalwidth;//將地圖向左平移一個完整的地圖寬度transform.position = tempPosition;//更新位置}}
}

配置
在這里插入圖片描述
在這里插入圖片描述
效果
在這里插入圖片描述

奔跑動畫切換

動畫配置
在這里插入圖片描述

修改PlayerController

private void FixedUpdate()
{ApplyMovement(); // 應用移動UpdateStatus();
}//判斷狀態 
private void UpdateStatus(){if(rb.velocity.x != 0){isRunning = true;}else{isRunning = false;}
}//播放動畫
private void UpdateAnimations(){animator.SetBool("isRunning", isRunning);
}

效果
在這里插入圖片描述

跳躍動畫,跳躍次數限制

配置跳躍動畫
在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述
修改PlayerController

[Header("跳躍 地面檢測")]
private float amountOfJumpsLeft;//當前可跳躍次數
private bool isGround;//是否是地面
private bool canJump;//能否跳躍
public int amountOfJumps = 1;//跳躍次數
public float groundCheckRadius;//地面檢測距離
public Transform groundCheck;//地面檢測點
public LayerMask whatIsGround;//地面檢測圖層void Start()
{rb = GetComponent<Rigidbody2D>();animator = GetComponent<Animator>();amountOfJumpsLeft = amountOfJumps;
}// 檢查輸入
private void CheckInput()
{movementInputDirection = Input.GetAxisRaw("Horizontal"); // 獲取水平輸入if (Input.GetButtonDown("Jump")){Jump(); // 如果按下跳躍鍵,則執行跳躍}
}// 跳躍
private void Jump()
{if (canJump){rb.velocity = new Vector2(rb.velocity.x, jumpForce); // 設置 y 方向的速度為跳躍力度amountOfJumpsLeft--;}
}//判斷能否跳躍
private void CheckIfCanJump()
{if (isGround && rb.velocity.y < 0){amountOfJumpsLeft = amountOfJumps;}if (amountOfJumpsLeft <= 0){canJump = false;}else{canJump = true;}
}//播放動畫
private void UpdateAnimations()
{animator.SetBool("isRunning", isRunning);animator.SetBool("isGround", isGround);animator.SetFloat("yVelocity", rb.velocity.y);
}//檢測
private void CheckSurroundings()
{//地面檢測isGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
}//視圖顯示檢測范圍
private void OnDrawGizmos()
{Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);
}

配置,這里配置了2段跳
在這里插入圖片描述
記得配置地面圖層為Ground
在這里插入圖片描述
效果
在這里插入圖片描述

角色添加2d物理材質,防止角色粘在墻上

在這里插入圖片描述
修改摩檫力為0
在這里插入圖片描述
配置
在這里插入圖片描述
效果
在這里插入圖片描述

如果角色移動時背景出現黑線條

方法一

添加材質
在這里插入圖片描述
配置
在這里插入圖片描述

方法二

我們創建了一個Sprite Atlas來將Spritesheet拖入其中
在這里插入圖片描述
把你的瓦片素材拖入
在這里插入圖片描述

墻壁滑行

配置滑墻動畫
在這里插入圖片描述

修改PlayerController

[Header("墻壁滑行")]
public float wallCheckDistance;//墻壁檢測距離
public Transform wallCheck;//墻壁檢測點
public float wallSlideSpeed;//墻壁滑行速度
private bool isTouchingWall;//是否接觸墻壁
private bool isWallSliding;//是否正在墻壁滑行// 移動
private void ApplyMovement()
{rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 設置 x 方向的速度//應用滑墻速度    if (isWallSliding){if (rb.velocity.y < -wallSlideSpeed){rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以應用墻壁滑行速度}}
}//是否正在墻壁滑行
private void CheckIfWallSliding()
{if (isTouchingWall && !isGround && rb.velocity.y < 0){isWallSliding = true;}else{isWallSliding = false;}
}//播放動畫
private void UpdateAnimations()
{animator.SetBool("isRunning", isRunning);animator.SetBool("isGround", isGround);animator.SetFloat("yVelocity", rb.velocity.y);animator.SetBool("isWallSliding", isWallSliding);
}//檢測
private void CheckSurroundings()
{//地面檢測isGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);//墻面檢測isTouchingWall = Physics2D.Raycast(wallCheck.position, transform.right, wallCheckDistance, whatIsGround);
}//視圖顯示檢測范圍
private void OnDrawGizmos()
{Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);Gizmos.DrawLine(wallCheck.position, wallCheck.position + wallCheckDistance * Vector3.right);
}

配置
在這里插入圖片描述
效果
在這里插入圖片描述

實現角色滑墻不可以通過移動離開且不可翻轉角色

// 移動
private void ApplyMovement()
{// 如果在地面上if (isGround){rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 設置 x 方向的速度}//應用滑墻速度    if (isWallSliding){if (rb.velocity.y < -wallSlideSpeed){rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以應用墻壁滑行速度}}
}// 翻轉角色
private void Flip()
{if (!isWallSliding){isFacingRight = !isFacingRight; // 改變面向方向的標志transform.Rotate(0.0f, 180.0f, 0.0f); // 旋轉角色}
}

效果
在這里插入圖片描述

空中運動控制

空氣阻力和移動速度控制

public float movementForceInAir;//空氣中的運動力
public float airDragMultiplier = 0.95f;//空氣阻力// 移動
private void ApplyMovement()
{// 如果在地面上if (isGround){rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 設置 x 方向的速度}// 如果不在地面上且不是在墻壁滑行且有水平輸入else if (!isGround && !isWallSliding && movementInputDirection != 0){Vector2 forceToAdd = new Vector2(movementForceInAir * movementInputDirection, 0);// 在空中施加的力rb.AddForce(forceToAdd);// 添加力到剛體if (Mathf.Abs(rb.velocity.x) > movementSpeed){rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y);// 限制水平速度}}// 如果不在地面上且不是在墻壁滑行且沒有水平輸入else if (!isGround && !isWallSliding && movementInputDirection == 0){rb.velocity = new Vector2(rb.velocity.x * airDragMultiplier, rb.velocity.y);// 應用空氣阻力}//應用滑墻速度    if (isWallSliding){if (rb.velocity.y < -wallSlideSpeed){rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以應用墻壁滑行速度}}
}

配置
在這里插入圖片描述
效果
在這里插入圖片描述

可變跳躍高度

長跳躍和短跳,長按和之前跳的和之前一樣高

public float variableJumpHeightMultiplier = 0.5f;// 檢查輸入
private void CheckInput()
{movementInputDirection = Input.GetAxisRaw("Horizontal"); // 獲取水平輸入if (Input.GetButtonDown("Jump")){Jump(); // 如果按下跳躍鍵,則執行跳躍}// 檢測是否松開Jumpif (Input.GetButtonUp("Jump")){rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * variableJumpHeightMultiplier);}
}

效果
在這里插入圖片描述

蹬墻跳

實現不輸入,點擊跳躍就從墻上跳下來,方向按鍵+跳躍控制左右蹬墻跳

[Header("蹬墻跳")]
public float wallHopForce; // 離開墻時的力
public float wallJumpForce; // 蹬墻跳時施加的力
public Vector2 wallHopDirection; // 離開墻時的方向向量
public Vector2 wallJumpDirection; // 蹬墻跳時的方向向量
private int facingDirection = 1; // 角色面向的方向,1右 -1左void Start()
{rb = GetComponent<Rigidbody2D>();animator = GetComponent<Animator>();amountOfJumpsLeft = amountOfJumps;//歸一化向量,因為我們只要向量的方向,而不考慮長度wallHopDirection = wallHopDirection.normalized;wallJumpDirection = wallJumpDirection.normalized;
}// 跳躍
private void Jump()
{// 如果可以跳躍并且不是在墻壁滑行狀態下if (canJump && !isWallSliding){rb.velocity = new Vector2(rb.velocity.x, jumpForce); // 設置 y 方向的速度為跳躍力度amountOfJumpsLeft--;}// 如果正在墻壁滑行且沒有輸入水平移動方向,并且可以跳躍else if(isWallSliding && movementInputDirection == 0 && canJump){isWallSliding = false;amountOfJumpsLeft--;// 計算添加的力量,使角色從墻壁上彈開Vector2 forceToAdd = new Vector2(wallHopForce * wallHopDirection.x * -facingDirection, wallHopForce * wallHopDirection.y);rb.AddForce(forceToAdd, ForceMode2D.Impulse);}// 如果正在墻壁滑行或者正在接觸墻壁,并且有水平移動輸入,并且可以跳躍else if((isWallSliding || isTouchingWall) && movementInputDirection != 0 && canJump){isWallSliding = false;amountOfJumpsLeft --;// 計算添加的力量,使角色從墻壁上跳躍Vector2 forceToAdd = new Vector2(wallHopForce * wallHopDirection.x * movementInputDirection, wallJumpForce * wallJumpDirection.y);rb.AddForce(forceToAdd, ForceMode2D.Impulse);}
}//判斷能否跳躍
private void CheckIfCanJump()
{if ((isGround && rb.velocity.y < 0) || isWallSliding){amountOfJumpsLeft = amountOfJumps;}if (amountOfJumpsLeft <= 0){canJump = false;}else{canJump = true;}
}// 翻轉角色
private void Flip()
{if (!isWallSliding){facingDirection *= -1;isFacingRight = !isFacingRight; // 改變面向方向的標志transform.Rotate(0.0f, 180.0f, 0.0f); // 旋轉角色}
}

配置
在這里插入圖片描述
運行效果
在這里插入圖片描述

完整代碼

using Unity.VisualScripting;
using UnityEngine;public class PlayerController : MonoBehaviour
{private float movementInputDirection; // 水平輸入方向private bool isFacingRight = true; // 玩家是否面向右側private Rigidbody2D rb;public float movementSpeed = 10.0f; // 移動速度public float jumpForce = 16.0f; // 跳躍力度private Animator animator;[Header("狀態")]public bool isRunning;[Header("跳躍 地面檢測")]public int amountOfJumps = 1;//跳躍次數public float groundCheckRadius;//地面檢測距離public Transform groundCheck;//地面檢測點public LayerMask whatIsGround;//地面檢測圖層private float amountOfJumpsLeft;//當前可跳躍次數private bool isGround;//是否是地面private bool canJump;//能否跳躍[Header("墻壁滑行")]public float wallCheckDistance;//墻壁檢測距離public Transform wallCheck;//墻壁檢測點public float wallSlideSpeed;//墻壁滑行速度public float movementForceInAir;//空氣中的運動力public float airDragMultiplier = 0.95f;//空氣阻力private bool isTouchingWall;//是否接觸墻壁private bool isWallSliding;//是否正在墻壁滑行[Header("可變高度")]public float variableJumpHeightMultiplier = 0.5f;[Header("蹬墻跳")]public float wallHopForce; // 離開墻時的力public float wallJumpForce; // 蹬墻跳時施加的力public Vector2 wallHopDirection; // 離開墻時的方向向量public Vector2 wallJumpDirection; // 蹬墻跳時的方向向量private int facingDirection = 1; // 角色面向的方向,1右 -1左void Start(){rb = GetComponent<Rigidbody2D>();animator = GetComponent<Animator>();amountOfJumpsLeft = amountOfJumps;//歸一化向量,因為我們只要向量的方向,而不考慮長度wallHopDirection = wallHopDirection.normalized;wallJumpDirection = wallJumpDirection.normalized;}void Update(){CheckInput(); // 檢查輸入CheckMovementDirection();UpdateAnimations();CheckIfCanJump();CheckIfWallSliding();CheckSurroundings();}private void FixedUpdate(){ApplyMovement(); // 應用移動UpdateStatus();}// 檢查玩家面朝的方向private void CheckMovementDirection(){if (isFacingRight && movementInputDirection < 0){Flip(); // 翻轉角色}else if (!isFacingRight && movementInputDirection > 0){Flip(); // 翻轉角色}}// 檢查輸入private void CheckInput(){movementInputDirection = Input.GetAxisRaw("Horizontal"); // 獲取水平輸入if (Input.GetButtonDown("Jump")){Jump(); // 如果按下跳躍鍵,則執行跳躍}if (Input.GetButtonUp("Jump")){rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * variableJumpHeightMultiplier);}}// 移動private void ApplyMovement(){// 如果在地面上if (isGround){rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 設置 x 方向的速度}// 如果不在地面上且不是在墻壁滑行且有水平輸入else if (!isGround && !isWallSliding && movementInputDirection != 0){Vector2 forceToAdd = new Vector2(movementForceInAir * movementInputDirection, 0);// 在空中施加的力rb.AddForce(forceToAdd);// 添加力到剛體if (Mathf.Abs(rb.velocity.x) > movementSpeed){rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y);// 限制水平速度}}// 如果不在地面上且不是在墻壁滑行且沒有水平輸入else if (!isGround && !isWallSliding && movementInputDirection == 0){rb.velocity = new Vector2(rb.velocity.x * airDragMultiplier, rb.velocity.y);// 應用空氣阻力}// //應用滑墻速度    if (isWallSliding){if (rb.velocity.y < -wallSlideSpeed){rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以應用墻壁滑行速度}}}// 移動private void ApplyMovement(){if(!isGround && !isWallSliding && movementInputDirection == 0){rb.velocity = new Vector2(rb.velocity.x * airDragMultiplier, rb.velocity.y);// 應用空氣阻力}else{rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y); // 設置 x 方向的速度}//應用滑墻速度    if (isWallSliding){if (rb.velocity.y < -wallSlideSpeed){rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);// 限制垂直速度以應用墻壁滑行速度}}}//判斷跑步狀態 private void UpdateStatus(){if(rb.velocity.x != 0){isRunning = true;}else{isRunning = false;}}// 翻轉角色private void Flip(){if (!isWallSliding){facingDirection *= -1;isFacingRight = !isFacingRight; // 改變面向方向的標志transform.Rotate(0.0f, 180.0f, 0.0f); // 旋轉角色}}//播放動畫private void UpdateAnimations(){animator.SetBool("isRunning", isRunning);animator.SetBool("isGround", isGround);animator.SetFloat("yVelocity", rb.velocity.y);animator.SetBool("isWallSliding", isWallSliding);}//判斷能否跳躍private void CheckIfCanJump(){if ((isGround && rb.velocity.y < 0) || isWallSliding){amountOfJumpsLeft = amountOfJumps;}if (amountOfJumpsLeft <= 0){canJump = false;}else{canJump = true;}}//檢測private void CheckSurroundings(){//地面檢測isGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);//墻面檢測isTouchingWall = Physics2D.Raycast(wallCheck.position, transform.right, wallCheckDistance, whatIsGround);}//是否墻壁滑行private void CheckIfWallSliding(){if (isTouchingWall && !isGround && rb.velocity.y < 0){isWallSliding = true;}else{isWallSliding = false;}}//視圖顯示檢測范圍private void OnDrawGizmos(){Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);Gizmos.DrawLine(wallCheck.position, wallCheck.position + wallCheckDistance * Vector3.right);}
}

源碼

整理好了我會放上來

完結

贈人玫瑰,手有余香!如果文章內容對你有所幫助,請不要吝嗇你的點贊評論和關注,以便我第一時間收到反饋,你的每一次支持都是我不斷創作的最大動力。當然如果你發現了文章中存在錯誤或者有更好的解決方法,也歡迎評論私信告訴我哦!

好了,我是向宇,https://xiangyu.blog.csdn.net

一位在小公司默默奮斗的開發者,出于興趣愛好,最近開始自學unity,閑暇之余,邊學習邊記錄分享,站在巨人的肩膀上,通過學習前輩們的經驗總是會給我很多幫助和啟發!php是工作,unity是生活!如果你遇到任何問題,也歡迎你評論私信找我, 雖然有些問題我也不一定會,但是我會查閱各方資料,爭取給出最好的建議,希望可以幫助更多想學編程的人,共勉~
在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/40598.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/40598.shtml
英文地址,請注明出處:http://en.pswp.cn/web/40598.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Web貴州旅游攻略系統-計算機畢業設計源碼16663

目 錄 第 1 章 引 言 1.1 選題背景與意義 1.2 國內外研究現狀 1.3 論文結構安排 第 2 章 系統的需求分析 2.1 系統可行性分析 2.1.1 技術方面可行性分析 2.1.2 經濟方面可行性分析 2.1.3 法律方面可行性分析 2.1.4 操作方面可行性分析 2.2 系統功能需求分析 2.3 系…

前端面試題18(js字符串特定內容查找方法)

在JavaScript中&#xff0c;有多種方法可以用來查找字符串中的特定內容。以下是一些常用的方法&#xff0c;包括它們的用途和示例代碼&#xff1a; 1. indexOf() indexOf() 方法返回指定文本在字符串中第一次出現的索引&#xff08;位置&#xff09;&#xff0c;如果沒有找到…

初學者打字練習平臺推薦

大牛打字練習平臺 (ccfoj.com) 適合人群&#xff1a;c初學者&#xff0c;10~20歲不定&#xff0c;有效提高對代碼的熟悉程度&#xff0c;以及鍛煉打字速度。 TypingClub TypingClub是一個免費的在線打字練習平臺&#xff0c;提供各種打字練習內容&#xff0c;從基礎到高級。…

pulsar單節點能開啟事務嗎?是不是真的

Apache Pulsar 支持事務&#xff0c;但是需要在分布式模式下運行。單節點模式下不支持 Pulsar 事務。事務功能在 Pulsar 中依賴于分布式的 BookKeeper 存儲服務&#xff0c;以確保事務的持久性和可靠性。 具體來說&#xff1a; 分布式模式和事務支持&#xff1a; 在分布式部署…

MyBatis(26)MyBatis 有哪些方式可以實現多數據源管理

在企業級應用開發中&#xff0c;有時需要同時操作多個數據庫&#xff0c;這就涉及到多數據源管理的問題。MyBatis作為一個流行的持久層框架&#xff0c;本身并沒有直接提供多數據源管理的功能&#xff0c;但是可以通過與Spring等框架結合&#xff0c;或者通過自定義方式來實現多…

【vue組件庫搭建04】使用vitepress搭建站點并部署到github

前言 基于vitePress搭建文檔站點&#xff0c;使用github pages進行部署 安裝VitePress 1.Node.js 18 及以上版本 2.npm add -D vitepress 3.npx vitepress init 4.將需要回答幾個簡單的問題&#xff1a; ┌ Welcome to VitePress! │ ◇ Where should VitePress initi…

Cesium 二三維熱力圖

Cesium 二三維熱力圖 原理&#xff1a;主要依靠heatmap.js包來實現 效果圖&#xff1a;

elementPlus-vue3-ts表格單選和雙選實現方式

記錄在vue3、ts、element-plus環境下表格單選和多選的實現方式 單選 html部分 <el-table...reftaskTableRefselect"selectClick"... ><el-table-column type"selection" width"50" />... </el-table>ts部分 const taskTabl…

三相異步電動機的起動方法

1. 引言 2. 三相籠型異步電動機德起動方法 3. 三相繞線型異步電動機的起動方法 4. 軟起動器起動 5. 參考文獻 1 引言 三相異步電動機結構簡單﹑價格低廉﹑運行可靠﹑維護方便&#xff0c;在工農業生產中得到了廣泛應用。為使電動機能夠轉動起來&#xff0c;并很快達到工作轉…

內存拷貝函數對比測試

內存拷貝函數 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <errno.h> #include <xmmintrin.h> // SSE Intrinsics#define SIZE_1K 1024 #define SIZE_1M (1024 * 1024)void* aligned_malloc…

低代碼平臺在企業數字化轉型中的關鍵角色與應用

隨著數字化轉型的深入推進&#xff0c;企業越來越依賴于快速、靈活的軟件開發和部署方案。傳統的軟件開發往往需要大量的編碼工作和專業技能&#xff0c;而低代碼開發平臺則通過簡化開發流程、降低技術門檻&#xff0c;為企業提供了一種新的解決方案。本文將探討低代碼開發平臺…

從零開始使用WordPress搭建個人網站并一鍵發布公網詳細教程

文章目錄 前言1. 搭建網站&#xff1a;安裝WordPress2. 搭建網站&#xff1a;創建WordPress數據庫3. 搭建網站&#xff1a;安裝相對URL插件4. 搭建網站&#xff1a;內網穿透發布網站4.1 命令行方式&#xff1a;4.2. 配置wordpress公網地址 5. 固定WordPress公網地址5.1. 固定地…

ChatGPT:為什么很多算法經過二分思想的優化就變成了logn

ChatGPT&#xff1a;為什么很多算法經過二分思想的優化就變成了logn 很多算法在經過二分思想優化后&#xff0c;時間復雜度變成 O(log?n)&#xff0c;這主要是因為二分思想能夠顯著減少問題的規模。具體來說&#xff0c;二分思想通常應用于那些問題規模可以通過每一步驟減半的…

【LabVIEW學習篇 - 2】:LabVIEW的編程特點

文章目錄 LabVIEW的編程特點圖形編程天然并行運行基于數據流運行 LabVIEW的編程特點 圖形編程 LabVIEW使用圖形化的圖形化編程語言&#xff08;G語言&#xff09;&#xff0c;用戶通過在程序框圖中拖放和連接各種節點&#xff08;Nodes&#xff09;來編寫程序。每個節點代表一…

什么是跨域?——詳解跨域問題及其解決方案

目錄 引言什么是跨域同源策略跨域的產生原因跨域的常見解決方案 JSONPCORS代理服務器nginx反向代理后端設置允許跨域 CORS的詳細實現 瀏覽器中的CORS支持服務器端的CORS配置 常見的跨域場景和解決方案 跨域請求API跨域加載資源 跨域的安全性考慮跨域調試技巧總結 引言 在現代…

python+playwright 學習-90 and_ 和 or_ 定位

前言 playwright 從v1.34 版本以后支持and_ 和 or_ 定位 XPath 中的and和or xpath 語法中我們常用的有text()、contains() 、ends_with()、starts_with() //*[text()="文本"] //*[contains(@id, "xx")] //

LLM - 循環神經網絡(RNN)

1. RNN的關鍵點&#xff1a;即在處理序列數據時會有順序的記憶。比如&#xff0c;RNN在處理一個字符串時&#xff0c;在對字母表順序有記憶的前提下&#xff0c;處理這個字符串會更容易。就像人一樣&#xff0c;讀取下面第一個字符串會更容易&#xff0c;因為人對字母出現的順序…

idea MarketPlace插件找不到

一、背景 好久沒用idea了&#xff0c;打開項目后沒有lombok&#xff0c;安裝lombok插件時發現idea MarketPlace插件市場找不到&#xff0c;需要重新配置代理源&#xff0c;在外網訪問時通過代理服務進行連接 二、操作 ### File-->setting 快捷鍵 Ctrl Alt S 遠端源地…

動手學深度學習(Pytorch版)代碼實踐 -循環神經網絡-53語言模型和數據集

53語言模型和數據集 1.自然語言統計 引入庫和讀取數據&#xff1a; import random import torch from d2l import torch as d2l import liliPytorch as lp import numpy as np import matplotlib.pyplot as plttokens lp.tokenize(lp.read_time_machine())一元語法&#xf…

類和對象深入理解

目錄 static成員概念靜態成員變量面試題補充代碼1代碼2代碼3如何訪問private中的成員變量 靜態成員函數靜態成員函數沒有this指針 特性 友元友元函數友元類 內部類特性1特性2 匿名對象拷貝對象時的一些編譯器優化 感謝各位大佬對我的支持,如果我的文章對你有用,歡迎點擊以下鏈接…