• Unity —— 复建(day1)


    图片素材的切割

            1.选择需要切割的图片,点击Sprite Editor按钮

     2.选择对应的切割方式,输入需要切割的尺寸,Pivot代表的是切割的中心点位置

     

    Preset的用法

             Preset为预制的设置,设置过一次后,其他需要用到相同的设置的图片就可以直接指定

    点击Save按钮就可以保存当前的设置 

     

    图片渲染规则

            渲染图片在图层tag和序号相同的情况下,越下方的物体层级越高

            在下方的物体会遮盖上方的物体

     

    Sorting Group用法

            可以将整个子物体设置为一个图层,防止其他图层的一个渲染问题

    设置整个项目按照 Y 轴渲染

            设置Transparency Sort Mode以及Transparency Sort Axis

     

     实现 Player 基本移动

    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. public class Player : MonoBehaviour
    5. {
    6. //声明一个刚体组件
    7. private Rigidbody2D rb;
    8. //声明变量
    9. public float speed;
    10. private float inputX;
    11. private float inputY;
    12. private Vector2 movementInput;
    13. //Awake()在调用的时候执行
    14. private void Awake()
    15. {
    16. rb = GetComponent();
    17. }
    18. private void Update()
    19. {
    20. PlayerInput();
    21. }
    22. private void FixedUpdate()
    23. {
    24. Movement();
    25. }
    26. ///
    27. /// 将用户输入的X,Y转换为坐标
    28. ///
    29. private void PlayerInput()
    30. {
    31. inputX = Input.GetAxisRaw("Horizontal");
    32. inputY = Input.GetAxisRaw("Vertical");
    33. //如果同时按下横向移动和纵向移动,会对速度做一个削弱
    34. if(inputX != 0 && inputY != 0)
    35. {
    36. inputX *= 0.6f;
    37. inputY *= 0.6f;
    38. }
    39. movementInput = new Vector2(inputX, inputY);
    40. }
    41. ///
    42. /// 让角色进行移动
    43. ///
    44. private void Movement()
    45. {
    46. rb.MovePosition(rb.position + movementInput * speed * Time.deltaTime);
    47. }
    48. }

  • 相关阅读:
    JAVA【设计模式】适配器模式
    【Linux】Linux安装卸载JDK
    全景视频拼接的关键技术与步骤
    教你几招,轻松实现视频转音频
    初识rust
    机器学习文献|基于循环细胞因子特征,通过机器学习算法预测NSCLC免疫治疗结局
    重磅!Vertica集成Apache Hudi指南
    【QT】Qt 使用MSVC2017找不到编译器的解决办法
    Java全栈
    改造xxl-job适配nacos注册中心
  • 原文地址:https://blog.csdn.net/m0_51743362/article/details/126697329