找茬小王子 2023-11-21 10:21 采纳率: 50%
浏览 2
已结题

根据算法提供的角度值实时切换显示的图片,如何让图片切换的更丝滑

做了一个3D图片切换的工具,根据算法提供的人眼角度值来自动切换当前显示的3D图片,反复用了很多种方法发现图片切换时,切换的动作都非常僵硬,有什么方法可以让它切换的更顺畅,就像视频播放的感觉,图片的大小是3840*2160,屏幕的大小也是这个分辨率,图片要全屏显示

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-11-21 12:04
    关注

    【相关推荐】



    • 你可以看下这个问题的回答https://ask.csdn.net/questions/187424
    • 我还给你找了一篇非常好的博客,你可以看看是否有帮助,链接:多达288种动态效果的侧滑菜单开源库,满足您项目的各种需求
    • 您还可以看一下 李月喜老师的企业微信开发第三方应用开发篇课程中的 最小应用提审上线小节, 巩固相关知识点
    • 除此之外, 这篇博客: 400行代码实现双人对战五子棋(适合新手入门)中的 6.能通过点击交替生成棋子之后需要的就是对游戏结束条件的判断,同时调用接口将结果传出,判断胜利比较麻烦,基本原理是对白子和黑子中的每一个点进行四个方向上的判断,判断是否连成5个或者是连成4个且至少存在两个空白位置,代码如下: 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
      //判断是否游戏结束,在onDraw方法内调用
          public void checkGameOver() {
              boolean whiteWin = checkFiveInLine(mWhites);
              boolean blackWin = checkFiveInLine(mBlacks);
              if (whiteWin || blackWin) {
                  isGameOver = true;
                  if (onGameListener != null) {
                      onGameListener.onGameOVer(whiteWin ? WHITE_WIN : BLACK_WIN);
                  }
              }
          }
      
          private boolean checkFiveInLine(List<Point> points) {
              for (Point point : points) {
                  int x = point.x;
                  int y = point.y;
                  //水平方向的检查
                  boolean isWin1 = checkHorizontal(x, y, points);
                  //检查垂直方向
                  boolean isWin2 = checkVertical(x, y, points);
                  //左斜方向的检查
                  boolean isWin3 = checkDiagonalLeft(x, y, points);
                  //右斜方向的检查
                  boolean isWin4 = checkDiagonalRight(x, y, points);
                  //任意方向五子连珠 , 游戏结束
                  if (isWin1 || isWin2 || isWin3 || isWin4) {
                      return true;
                  }
              }
              return false;
          }
      
          private boolean checkDiagonalRight(int x, int y, List<Point> points) {
              int count = 1;
              int emptyCount = 0;
              //往右上方向的判断
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x + i, y - i);
                  if (points.contains(point)) {
                      count++;
                  } else {
                      if (!mWhites.contains(point) && !mBlacks.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              //往左下方向的判断
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x - i, y + i);
                  if (points.contains(point)) {
                      count++;
                  } else {
                      if (!mWhites.contains(point) && !mBlacks.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              return false;
          }
      
          private boolean checkVertical(int x, int y, List<Point> points) {
              int count = 1;
              int emptyCount = 0;
              //往上遍历
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x, y - i);
                  if (points.contains(point)) {
                      count++;
                  } else {
                      if (!mBlacks.contains(point) && !mWhites.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              Log.i(TAG, "checkDiagonalLeft: " + count + ":" + emptyCount);
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              //往下遍历
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x, y + i);
      
                  if (points.contains(point)) {
                      count++;
                  } else {
                      if (!mBlacks.contains(point) && !mWhites.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              Log.i(TAG, "checkDiagonalLeft: " + count + ":" + emptyCount);
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              return false;
          }
      
          //左斜方向的判断
          private boolean checkDiagonalLeft(int x, int y, List<Point> points) {
              int count = 1;
              //往左上方向遍历
              int emptyCount = 0;
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x - i, y - i);
                  if (points.contains(point)) {
                      count++;
                  } else {
                      if (!mBlacks.contains(point) && !mWhites.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              //往右下方向的判断
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x + i, y + i);
                  if (points.contains(point)) {
                      count++;
                  } else {
                      if (!mBlacks.contains(point) && !mWhites.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              return false;
          }
      
          //检查水平方向
          private boolean checkHorizontal(int x, int y, List<Point> points) {
              int count = 1;
              int emptyCount = 0;
              //往左遍历
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x - i, y);
                  if (points.contains(point)) { // 是否包含点
                      count++;
                  } else {
                      if (!mBlacks.contains(point) && !mWhites.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              //往右遍历
              for (int i = 1; i < MAX_IN_LINE; i++) {
                  Point point = new Point(x + i, y);
                  if (points.contains(point)) {
                      count++;
                  } else {
                      if (!mBlacks.contains(point) && !mWhites.contains(point)) {
                          emptyCount++;
                      }
                      break;
                  }
              }
              if ((count == MAX_IN_LINE - 1 && emptyCount > 0) || count == MAX_IN_LINE) {
                  return true;
              }
              return false;
          }
      

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 12月5日
  • 创建了问题 11月21日

悬赏问题

  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义
  • ¥15 嵌入式--定时器使用
  • ¥20 51单片机学习中的问题
  • ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
  • ¥15 Python中knn问题
  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库