12 lines
380 B
TypeScript
Raw Normal View History

2022-12-01 22:26:41 +08:00
import { SpriteFrame } from "cc"
2022-11-27 23:23:47 +08:00
const INDEX_REG = /\((\d+)\)/
const getNumberWithinString = (str: string) => parseInt(str.match(INDEX_REG)?.[1] || '0')
export const sortSpriteFrame = (spriteFrame: Array<SpriteFrame>) =>
spriteFrame.sort((a, b) => getNumberWithinString(a.name) - getNumberWithinString(b.name))
export const rad2Angle = (rad: number) => rad / Math.PI * 180