学习Cocos第一天-鼠标控制人物移动

通过按下鼠标时移动进行人物移动


import {
    _decorator, Component, Vec3, systemEvent, SystemEvent, EventMouse, Animation, Vec2 } from 'cc';
const {
    ccclass, property } = _decorator;

@ccclass("PlayerController")
export class PlayerController extends Component {
   

    /**
     *      num 代表
     *      0:鼠标左键
     *      1:鼠标中键
     *      2:鼠标右键
     */

     /**
      *     down 按下时
      *     move 移动
      *     up 松开时
      * 
      */

      /**
       * 点击屏幕
       * 获取物体当前坐标  objCurPosition
       * 获取鼠标当前坐标   cursCurPosition
       * 获取鼠标移动坐标   cursMovePostion
       * 计算移动向量      subVec3
       *  移动物体          
       */
    
    /* class member could be defined like this */
    // dummy = '';

    /* use `property` decorator if your want the member to be serializable */
    // @property
    // serializableDummy = 0;

    // for fake tween
    //定义对象接受
    private _mouseState:any = {
   
        mouseDown:false,
        mouseMove:false,
        mouseUp:false
    }

    //鼠标按下时的初始位置
    private _cusInitPos:Vec3 = new Vec3(0,0,0);
    // 是否接收到跳跃指令
    private _startJump: boolean = false;
    // 跳跃步长
    private _jumpStep: number = 0;
    // 当前跳跃时间
    private _curJumpTime: number = 0;
    // 每次跳跃时常
    private _jumpTime: number = 0.1;
    // 当前跳跃速度
    private _curJumpSpeed: number = 0;
    // 当前角色位置
    
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

痛苦的键盘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值