【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.mzph.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 匿名对象拷贝对象时的一些编译器优化 感谢各位大佬对我的支持,如果我的文章对你有用,欢迎点击以下链接…