【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是生活!如果你遇到任何问题,也欢迎你评论私信找我, 虽然有些问题我也不一定会,但是我会查阅各方资料,争取给出最好的建议,希望可以帮助更多想学编程的人,共勉~
相关文章:

【unity实战】使用旧输入系统Input Manager 写一个 2D 平台游戏玩家控制器——包括移动、跳跃、滑墙、蹬墙跳
最终效果 文章目录 最终效果素材下载人物环境 简单绘制环境角色移动跳跃视差和摄像机跟随效果奔跑动画切换跳跃动画,跳跃次数限制角色添加2d物理材质,防止角色粘在墙上如果角色移动时背景出现黑线条方法一方法二 墙壁滑行实现角色滑墙不可以通过移动离开…...

【实战】EasyExcel实现百万级数据导入导出
文章目录 前言技术积累实战演示实现思路模拟代码测试结果 前言 最近接到一个百万级excel数据导入导出的需求,大概就是我们在进行公众号API群发的时候,需要支持500w以上的openid进行群发,并且可以提供发送openid数据的导出功能。可能有的同学…...

Graalvm配置文件与Feature和Substitute机制介绍
GraalVM介绍 GraalVM提前将Java应用程序编译成独立与机器码二进制文件(可执行文件、动态库文件),如windows系统中的exe文件和dll文件。与在Java虚拟机(JVM)上运行的应用程序相比,这些二进制文件更小,启动速…...

Appium adb 获取appActivity
方法一(最简单有效的方法) 通过cmd命令,前提是先打开手机中你要获取包名的APP adb devices -l 获取连接设备详细信息 adb shell dumpsys activity | grep mFocusedActivity 有时获取到的不是真实的Activity 方法二 adb shell monkey -p …...

调整分区失败致盘无法访问:深度解析与数据恢复全攻略
调整分区失败盘打不开的困境 在计算机的日常维护与管理中,调整磁盘分区是常见的操作之一,旨在优化存储空间布局、提升系统性能或满足特定应用需求。然而,当这一操作未能如预期般顺利进行,反而导致分区调整失败,进而使…...

试用笔记之-汇通计算机等级考试软件一级Windows
首先下载汇通计算机等级考试软件一级Windows http://www.htsoft.com.cn/download/htwork.rar...

Java的NIO体系
目录 NIO1、操作系统级别下的IO模型有哪些?2、Java语言下的IO模型有哪些?3、Java的NIO应用场景?相比于IO的优势在哪?4、Java的IO、NIO、AIO 操作文件读写5、NIO的核心类 :Buffer(缓冲区)、Channelÿ…...

自下而上的选股与自上而下的选股
一起学习了《战胜华尔街》,不知道大家有没有这么一种感受:林奇的选股方法是典型的自下而上的选股方法。虽然这一点没有单独拎出来讨论过,但在《从低迷中寻找卓越》《如何通过财务指标筛选股票?》《边逛街边选股?》《好…...

Tech Talk:智能电视eMMC存储的五问五答
智能电视作为搭载操作系统的综合影音载体,以稳步扩大的市场规模走入越来越多的家庭,成为人们生活娱乐的重要组成部分。存储部件是智能电视不可或缺的组成部分,用于保存操作系统、应用程序、多媒体文件和用户数据等信息。智能电视使用eMMC作为…...

scikit-learn教程
scikit-learn(通常简称为sklearn)是Python中最受欢迎的机器学习库之一,它提供了各种监督和非监督学习算法的实现。下面是一个基本的教程,涵盖如何使用sklearn进行数据预处理、模型训练和评估。 1. 安装和导入包 首先确保安装了…...

CentOS 7 搭建rsyslog日志服务器
CentOS 7 搭建rsyslog日志服务器 前言一、IP地址及主机名称规划1.修改主机名 二、配置rsyslog日志服务器1.安装rsyslog服务2.编辑/etc/rsyslog.conf 文件3.启动并启用rsyslog服务4.验证端口是否侦听 三、在rsyslog日志服务器上配置firewalld防火墙四、配置rsyslog日志客户端1.编…...

使用Spring Boot Actuator监控应用健康状态
使用Spring Boot Actuator监控应用健康状态 大家好,我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!今天我们将探讨如何利用Spring Boot Actuator来监控和管理应用程序的…...

leetcode刷题:vector刷题
🔥个人主页:guoguoqiang. 🔥专栏:leetcode刷题 1.只出现一次的数字 这道题很简单,我们只需要遍历一次数组即可通过异或运算实现。(一个数与自身异或结果为0,任何数与0异或还是它本身) class Solut…...

CGI面试题及参考答案
什么是CGI?它在Web服务器与应用程序之间扮演什么角色? CGI(Common Gateway Interface) 是一种标准协议,它定义了Web服务器与运行在服务器上的外部程序(通常是脚本或应用程序)之间的通信方式。简单来说,CGI充当了一个桥梁,使得Web服务器能够将用户的请求传递给后端程序…...

论文调研_物联网漏洞检测综述
A Review of IoT Firmware Vulnerabilities and Auditing Techniques 研究背景:物联网设备在工业、消费类等各个领域得到了广泛应用,实现了更高的自动化和生产率。然而,这些连网设备的高度依赖也带来了一系列网络安全威胁,特别是…...

Java学习【IO流:深入理解与应用(上)】
Java学习【IO流:深入理解与应用(上)】 🍃1.IO流体系结构🍃2.FileOutputStream🍁2.1FileOutputStream写数据的三种方式🍁2.2换行和续写 🍃3.FileInputStream🍁3.1每次读取…...

干货系列:SpringBoot3第三方接口调用10种方式
环境:SpringBoot.3.3.0 1、简介 在项目中调用第三方接口是日常开发中非常常见的。调用方式的选择通常遵循公司既定的技术栈和架构规范,以确保项目的一致性和可维护性。无论是RESTful API调用、Feign声明式HTTP客户端、Apache HttpClient等调用方式&…...

KVM性能优化之CPU优化
1、查看kvm虚拟机vCPU的QEMU线程 ps -eLo ruser,pid,ppid,lwp,psr,args |awk /^qemu/{print $1,$2,$3,$4,$5,$6,$8} 注:vcpu是不同的线程,而不同的线程是跑在不同的cpu上,一般情况,虚拟机在运行时自身会点用3个cpus,为保证生产环…...

lua中判断2个表是否相等
当我们获取 table 长度的时候无论是使用 # 还是 table.getn 其都会在索引中断的地方停止计数,而导致无法正确取得 table 的长度,而且还会出现奇怪的现象。例如:t里面有3个元素,但是因为最后一个下表是5和4,却表现出不一…...

uni-app 自定义支付密码键盘
1.新建组件 payKeyboard .vue <template><view class"page-total" v-show"isShow"><view class"key-list"><view class"list" v-for"(item,index) in keyList" :class"{special:item.keyCode190…...

抖音微短剧小程序源码搭建:实现巨量广告数据高效回传
在数字化营销日益盛行的今天,抖音微短剧小程序已成为品牌与观众互动的新渠道。这些短小精悍的剧目不仅能迅速抓住用户的注意力,还能有效提升品牌的知名度和用户黏性。然而,想要充分利用这一营销工具,关键在于如何高效地追踪广告数…...

springboot数字化医院产科系统源码
目录 一、系统概述 二、开发环境 三、功能设计 四、功能介绍 一、系统概述 数字化产科是为医院产科量身定制的信息管理系统。它管理了孕妇从怀孕开始到生产结束42天一系列医院保健服务信息。该系统由门诊系统、住院系统、数据统计模块三部分组成,与医院HIS、LI…...

uniapp微信接口回调 response.sendRedirect nginx 报404错误
如题 参考 uniapp打包H5时,访问index.html页面白屏报错net::ERR_ABORTED 404 - 简书 nginx中修改 配置文件 location / { try_files $uri $uri/ /index.html; root html; index index.html index.htm; } uniapp里配置 重新载入...

Python系统教程02
巩固 input()输出函数 回顾 1 、 input()函数: 在 input()函数输入时,输入的内容一定为字符串类型。 2 、条件分支语句: 每一个 if 语句可以看成一个个体,elif 和 else 都是一个 if 个体的一部分,每一个 if 个体 运…...

JS面试题6——深拷贝和浅拷贝
它们都是用来复制的 1. 浅拷贝(只复制引用,而未复制真正的值) /* 简单赋值 */ var arr1 [a, b, c, d]; var arr2 arr1; /* Object.assign实现的也是浅拷贝 */ var obj1 {a:1, b:2} var obj2 Object.assign(obj1); 2. 深拷贝(是…...

Scrapy实现关键词搜索的数据爬取
爬虫技术对于从互联网上获取数据和信息非常重要,而scrapy作为一款高效、灵活和可扩展的网络爬虫框架,能够简化数据爬取的过程,对于从互联网上爬取数据的工作非常实用。本文将介绍如何使用scrapy实现关键词搜索的数据爬取。 Scrapy的介绍 Sc…...

【Linux】ip命令详解
Linux中的ip命令是一个功能强大的网络配置工具,用于显示或操作路由、网络设备、策略路由和隧道。以下是关于ip命令的详细解释: 一、ip命令介绍 简介:ip命令是一个用于显示或操作路由、网络设备、策略路由和隧道的Linux命令行工具。它取代了早期的ifconfig命令,并提供了更多…...

软降工程学系统实现
一、程序编码 程序编码是设计的继续,将软件设计的结果翻译成用某种程序设计语言描述的源代码。 程序编码涉及到方法、工具和过程。 程序设计风格和程序设计语言的特性会深刻地影响软件的质量和可维护性。 要求源程序具有良好的结构性和设计风格。 程序设计风格…...

001 SpringMVC介绍
文章目录 基础概念介绍BS和CS开发架构应用系统三层架构MVC设计模式 SpringMVC介绍SpringMVC是什么SpringMVC与Spring的联系为什么要学习SpringMVC 六大组件介绍六大组件(MVC组件其他三大组件)说明 基础概念介绍 BS和CS开发架构 一种是C/S架构,也就是客户端/服务器…...

深入解析scikit-learn中的交叉验证方法
交叉验证是机器学习中用于评估模型性能的重要技术,它可以帮助我们理解模型在未知数据上的泛化能力。scikit-learn(简称sklearn)是一个广泛使用的Python机器学习库,提供了多种交叉验证方法。本文将详细介绍scikit-learn中提供的交叉…...