找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2793|回复: 1

[教程源码] 分享一个点击2D游戏移动NPC的代码

[复制链接]

12

主题

13

回帖

37

积分

按键手机班学员

鲜花
0
猫粮
121
发表于 2020-9-8 21:27:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 denis 于 2020-9-8 23:28 编辑

Call 动态npc截图("酒店老板",{498,196,552,257},9)//第一步截图保存,默认9张图片

Function 动态npc截图(NpcName, Rang, SearchingTimes)

    Dim PicturesPath

    For SearchingTimes
                        
        PicturesPath = "/sdcard/pictures/" & NpcName & "/" & NpcName & "动态" & SearchingTimes & ".png"

        SnapShot PicturesPath,Rang(0),Rang(1),Rang(2),Rang(3)

        Delay 300

        SearchingTimes = SearchingTimes - 1

    Next

End Function





Call SearchMovingNpc("酒店老板",{373, 96, 627, 322},9)//第二步寻找,但注意范围一定要比截图的大很多

Function SearchMovingNpc(NpcName, Rang, SearchingTimes)

    Dim PicturesPath,NpcPictures

    dim 结果 = Dir.Exist("/sdcard/pictures/SearchNpc.txt")

    If 结果 = 1 Then
       
        Dir.Delete "/sdcard/pictures/SearchNpc.txt"

        zmFile.Write("/sdcard/pictures/SearchNpc.txt","")
               
    End If

    Delay 2000

    For SearchingTimes

        PicturesPath = "/sdcard/pictures/" & NpcName & "/" & NpcName & "动态" & SearchingTimes & ".png"

        NpcPictures = "|" & PicturesPath

        File.Append "/sdcard/pictures/SearchNpc.txt", NpcPictures

        SearchingTimes = SearchingTimes - 1

    Next

    NpcPictures = File.Read("/sdcard/pictures/SearchNpc.txt")

    TracePrint NpcPictures

    ret = zm.FindPic(Rang(0),Rang(1),Rang(2),Rang(3),NpcPictures,"0.70-0.85", 10000)
    If ret Then

        TracePrint "找到了"

        TracePrint ret(3)

        Tap ret(1)+30,ret(2)+30

    Else

        TracePrint "没有找到"

    End If   

End Function




(^-^)V


楼主热帖

0

主题

11

回帖

12

积分

按键手机班学员

鲜花
0
猫粮
99
发表于 2020-9-12 07:17:13 | 显示全部楼层
o(∩_∩)o
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|紫猫编程学园

GMT+8, 2024-4-27 12:56

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表