Category Archives: Hello World

Hello World

sp.Skeleton动画Listener汇总

简单总结一下cocos骨骼动画的各种几个回调监听,可以进行更精确的控制特效,免得到时只会this.schedule

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    //整体开始是调用一次
    this.roleAnimation.setStartListener((trackEntry)=>{
        console.log('---->> HeroAI roleAnimation, setStartListener:', trackEntry.trackIndex, trackEntry.animation.name);
    });
    //动画关闭时调用,在setEndListener之后
    this.roleAnimation.setDisposeListener((trackEntry)=>{
        console.log('---->> HeroAI roleAnimation, setDisposeListener:', trackEntry.trackIndex, trackEntry.animation.name);
    });
    //整体结束时调用
    this.roleAnimation.setEndListener((trackEntry)=>{
        console.log('---->> HeroAI roleAnimation, setEndListener:', trackEntry.trackIndex, trackEntry.animation.name);
    });
    //中断时调用,在setEndListener之前
    this.roleAnimation.setInterruptListener((trackEntry)=>{
        console.log('---->> HeroAI roleAnimation, setInterruptListener:', trackEntry.trackIndex, trackEntry.animation.name);
    });
    //每次循环结束时调用
    this.roleAnimation.setCompleteListener((trackEntry)=>{{
        console.log('---->> HeroAI roleAnimation, setCompleteListener:', trackEntry.trackIndex, trackEntry.animation.name);
    });

——
over
转载请注明出处:http://www.jiangkl.com/2025/04/cocos-skeleton-listener

Hello World

cocos.tween动画,时间线控制汇总

本文主要简绍cc.tween与sequence、delay、parallel、repeat和call的各种搭配、混合使用,实现事件序列的串并行控制
1. 简单串行

1
2
3
4
5
6
7
8
// 示例代码,先执行动作1、再执行动作2、然后执行回调
cc.tween(node)
    .to(time1, { position: newPosition }) // 动作1
    .to(time2, { angle: newAngle }) // 动作2
    .call(() => {
        // console.log('>> cc.tween end')
    })
    .start();

2. 并行parallel、延迟delay

1
2
3
4
5
6
7
8
9
// 示例代码,先同步执行动作1和动作2、然后延迟0.5秒、然后执行动作3
cc.tween(node)
    .parallel(
        cc.tween().to(time1, { position: newPosition1 }),// 动作1
        cc.tween().to(time2, { angle: newAngle }),// 动作2
    )
    .delay(0.5)
    .to(time2, { position: newPosition2 }) // 动作3
    .start();

3. 并行parallel、串行sequence、重复repeat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 示例代码 串并行混排、重复
cc.tween(node)
    .repeat(3,  // 让整个 sequence 重复 3 次
        cc.tween().sequence( //先执行第一个parallel,然后等待0.5秒、然后执行第二个parallel
            cc.tween().parallel( //先动作1与动作2串行
                cc.tween().to(1, { position: cc.v2(200, 200) }),  // 动作1
                cc.tween().to(1, { angle: 180 }) //动作2
            ),
            cc.tween().delay(0.5),
            cc.tween().parallel( //后动作3与动作4
                cc.tween().to(1, { position: cc.v2(-200, -200) }).to(1, { position: cc.v2(0, -200) }), //动作3,包含两个串行的子动作
                cc.tween().to(1, { color: cc.Color.RED }) //动作4
            )
        ).call(()=>{
               console.log('>> repeat once'); //每次repeat可以单独定义回调
        }),
 
    ).call(()=>{
        console.log('>> repeat end');} //整体完成的回调
    ).start();

——
over
转载请注明出处:http://www.jiangkl.com/2025/02/cocos-tween_timeline

Hello World

cocos.tween动画,移动曲线参数汇总

1. 缓动曲线:

1
2
3
4
5
6
7
8
9
10
11
// 示例代码
cc.tween(node)
    .to(time, { position: newPosition }, { easing: "sineInOut" }) // 先慢后快
    .start();
// 常用 easing 类型
// "sineIn"	开始慢,后面加速
// "sineOut"	开始快,后面减速
// "sineInOut"	先慢-加速-再慢
// "quadIn"	二次方曲线加速
// "quadOut"	二次方曲线减速
// "quadInOut"	二次方曲线平滑过渡

2. 贝塞尔曲线(Bezier Curve):

1
2
3
4
5
6
7
//示例代码
cc.tween(node)
    .bezierTo(time, cc.v2(100, 200), cc.v2(200, 300), cc.v2(300, 100)) // 1秒内按贝塞尔曲线移动
    .start();
// bezierTo(time, control1, control2, endPos)
// control1 和 control2 是控制点,决定曲线形状。
// endPos 是终点,节点沿着曲线到达该点。

3. 分步依次移动,使用 sequence() 组合多个 to():

1
2
3
4
5
6
7
//示例代码
cc.tween(node)
    .sequence(
        cc.tween().to(time1, { position: cc.v2(100, 200) }, { easing: "sineOut" }),
        cc.tween().to(time2, { position: cc.v2(200, 100) }, { easing: "sineIn" })
    )
    .start();

——
over
转载请注明出处:http://www.jiangkl.com/2025/02/cocos_tween_positin_easing

Hello World

用python提取Excel内的附件mp4

收到一个Excel文档,里面有两段内嵌的mp4视频,手头mac版的Excel打不开这俩附件。其实以前也发现过,无论是内嵌的doc、还是其他文件,mac版的excel似乎都打不开,但那时身边有用 windows的同事,让他帮忙打开再导出就好了。现在身边人全是mac本,手头唯一windows台式机平时只玩游戏,甚至没装office~~
先到的第一个方法是各种在线文档工具,但是,试了google和腾讯的,上传以后都不行。按说微软自家的在线文档总可以吧,好容易登陆了,TM上传这个Excel文件一直失败…
既然此路不通,那就从头开始:给windows装个office~~记得以前有试用版,装好以后能试用一个月。哪知现在的office365不付钱就找不到下载入口(⊙o⊙)…。有想着下载一个旧版的office,最好是破解版的,找了几个渠道,要么不是正常的下载包、要么到了百度网盘~~然后进网盘提示资源已经没了…(还送,好久不用windows,破解软件这么难找了吗 O(∩_∩)O哈哈~)
最后没办法,搜索引擎也找不到靠边的答案,问chatgpt,在chatgpt的提示下,一步步用python解出了附件,具体大概分下面两步:
1. 将excel备份一份,然后将扩展名改成“.zip”,然后解压,按AI的说法,运气好的话,mp4文件直接就在解压包/xl/embeddings目录底下~~我的运气不好,里面是两个bin文件,按chatgpt的说法,mp4数据就包在这个bin里
2. 调下面python脚本,处理bin文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    import olefile #需要安装olefile库
    ole = olefile.OleFileIO('xx/xl/embeddings/oleObject2.bin')
    print(ole.listdir())
    streams = ole.listdir()
    print(streams) #打印出具体的数据流,mp4可能在\x01Ole10Native中,也可能在其他流中
    #提取mp4数据流
    if ole.exists('\x01Ole10Native'):
        with ole.openstream('\x01Ole10Native') as stream:
            data = stream.read()
        # 保存到缓冲文件
        with open('temp.bin', 'wb') as f:
            f.write(data)
        print("Data from \\x01Ole10Native saved as output.bin")
    else:
        print("\\x01Ole10Native stream not found")
    ole.close()
    # 从 MP4 文件中提取数据
    with open('temp.bin', 'rb') as f:
        data = f.read() 
    # 自动查找 MP4 文件头 ("ftyp")
    data_start = data.find(b'ftyp')
    if data_start == -1:
        print("MP4 header not found. The file may not contain valid MP4 data.")
        exit()
    print(f"MP4 header found at offset: {data_start}")
    # 从 mp4 文件头开始提取数据
    # mp4文件头在"ftyp"之前可能还有四个字节空位,具体的可以使用https://hexed.it之类的工具打开二进制文件查看
    data_start = data_start - 4 
    output_file = 'extracted_video.mp4' #输出mp4文件名
    with open(output_file, 'wb') as out_f:
        out_f.write(data[data_start:])
    print(f"File extracted successfully as {output_file}")

———-
over,转载请注明出处:http://www.jiangkl.com/2024/12/excel_mp4_python

Hello World

css-display-flex各种居中对齐,强迫症的福音

先看页面效果

html+css:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
    <style>
        div.main{
            margin-left: 2%; width :96%;
            .title{
                width: 100%;display: flex;justify-content: space-between;
                align-items: center;padding: 10px 0;line-height: 16px;
                span{
                    font-size: 16px;color: #333;width: 200px; text-align: left;
                }
                >div{/*右侧单号、箭头*/
                    display: inline-flex;justify-content: right;align-items: center;width: 100px;
                    span{
                        font-size: 14px;color: #999;
                    }
                    img{
                        width: 14px; height: 14px; margin-right: -2px;/*修正png图的框框*/
                    }
                }
            }
            .content{
                width: 100%;
                .order{
                    background-color: #fff;border-radius: 5px;display: flex;
                    justify-content: space-between;align-items: center; margin: 10px 0;    
                    >img{/*商品图*/
                        width: 80px;height: 80px; border: 1px solid blue;
                        border-radius: 5px; margin: 10px;
                    }
                    >div{/*商品图右侧详情*/
                        display: inline-flex;flex-direction: column;
                        justify-content: space-between;align-items: center;
                        height: 80px;margin-right: 10px;
                        >div{/*单号、时间*/
                            display: flex; font-size: 16px;line-height: 16px;
                            span{
                                display:block;font-size: 16px;
                                color: #333;width: 200px;
                                text-align: left;width: 100%;
                            }
                            >span:last-child{/*时间*/
                                font-size: 11px;color: #999;text-align: right;
                            }
                        }
                        >span{/*商品名*/
                            display:inline-block;font-size: 18px;
                            color: #333;font-weight: 900;
                            text-align: left;width: 100%;
                        }
                        >span:last-child{/*规格*/
                            font-size: 11px;color: #999;
                            line-height: 12px;margin-top: -20px;/*拉进商品名与规格*/
                        }
 
                    }
                }
            }
        }
    </style>
    <div class="main">
        <div class="title">
            <span>近期订单</span>
            <div>
                <span>查看全部订单</span>
                <img src="arrow_right_small.png">
            </div>
        </div>
        <div class="content">
            <div class="order">
                <img src="IMG_1101.JPG">
                <div>
                    <div>        
                        <span>订单号: 123456789</span>
                        <span>2024-07-23 10:01:31</span>
                    </div>
                    <span>5090系列散热格窗............</span>
                    <span>红色、水冷款</span>
                </div>
 
            </div>
...

——-
over~~
后记:
记得上小学时,某日,学校请来村里老木匠,做桌椅。木匠逐个做好各种课桌的部件:桌子腿、桌面、桌洞底板,然后一个个部件拼接起来,再在接口处敲几个木削进去,一张桌子完工。老师盯着这一切,跟我们说:看到了吧,老师傅做东西就是有谱,每个部件都刚刚好,一个人轻松组装;这要是不靠谱的小年轻木匠,三五个人辅助也也不见的能拼到一起,而且拼出来桌子可能还桌腿不平摇摇晃晃
每次写页面、css,脑子里想的都是几个人辅助一起拼桌子的画面…虽然前有firebug、后有chrome的开发工具,各种页面布局,也是要反复测试才能勉强完成设计图的目标。当然,大部分时候都不能完全实现效果图,最后就彻底改成position: absolute,各种算坐标,绝对定位~~给人感觉就是:虽然呈现在眼前的貌似是一张桌子,但后面其实是各种钉子、角铁钉住、甚至胶带粘在一起的 O(∩_∩)O哈哈~
近期写小程序,再次开始搞css,发现display:flex“弹性盒模型”真的很好用,这里记个布局范式,便于以后查阅