金猪脚本Autojs之UI下对话框文件选择器

"ui";




 
**脚本源码:金猪脚本
**脚本作用:停止运行
*-*学习交流扣扣裙:741-318-378
ui.layout(
    <vertical>
        <button id="calc" align="center">文件选择</button>
        <text id="text_test" text="null"></text>
    </vertical>
);


function pathToArray(dir) {
    current_dir_array = new Array();
    current_dir_array = ["返回上级目录"];
    files.listDir(dir.join("")).forEach((i) => {
        if (files.isDir(dir.join("") + i)) {
            current_dir_array.push(i + "/");
        } else if (files.isFile(dir.join("") + i)) {
            current_dir_array.push(i);
        }
    });
    return current_dir_array;
}



ui.calc.click(() => {
    var current_dir_array, dir = ["/", "sdcard", "/"]; //存储当前目录
    function file_select(select_index) {
        switch (select_index) {
            case undefined:
                break;
            case -1:
                return;
            case 0:
                if (dir.length > 3) {
                    dir.pop();
                }
                break;
            default:
                if (files.isFile(files.join(dir.join(""), current_dir_array[select_index]))) {
                    let file_name = (files.join(dir.join(""), current_dir_array[select_index]))
                    toast(file_name)
                    ui.text_test.setText(file_name);
                    return;

                } else if (files.isDir(files.join(dir.join(""), current_dir_array[select_index]))) {
                    dir.push(current_dir_array[select_index])
                }

        };
        current_dir_array = pathToArray(dir)
        dialogs.select("文件选择", current_dir_array).then(n => {
            file_select(n)
        });
    };
    file_select();
});

学习 交流扣扣裙:74-13-18-378


 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,以下是一个使用Python编写的简单游戏脚本示例,该脚本控制一个玩家角色在屏幕上移动和跳跃: ```python import pygame # 初始化Pygame pygame.init() # 创建游戏窗口 screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption("My Game") # 加载玩家图像 player_image = pygame.image.load("player.png") player_rect = player_image.get_rect() player_rect.x = screen_width // 2 player_rect.y = screen_height // 2 # 设置玩家移动速度 player_speed = 5 # 设置跳跃参数 jump_height = 80 jump_speed = 5 jumping = False jump_count = 0 # 游戏循环 running = True while running: # 处理事件 for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # 处理玩家输入 keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: player_rect.x -= player_speed if keys[pygame.K_RIGHT]: player_rect.x += player_speed if keys[pygame.K_SPACE] and not jumping: jumping = True # 处理跳跃 if jumping: if jump_count >= jump_height: jumping = False jump_count = 0 else: player_rect.y -= jump_speed jump_count += jump_speed # 绘制游戏场景 screen.fill((255, 255, 255)) screen.blit(player_image, player_rect) pygame.display.flip() # 退出Pygame pygame.quit() ``` 这个脚本使用Pygame库创建了一个游戏窗口,并加载了一个玩家图像。玩家可以使用左右箭头控制移动,使用空格键进行跳跃。跳跃高度和速度可以通过调整脚本中的参数来更改。游戏循环处理事件和玩家输入,并在屏幕上绘制游戏场景。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值