Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Fucheng Yang yangfch3

🎯
Focusing
View GitHub Profile
@yangfch3
yangfch3 / BaseClass.lua
Created Sep 6, 2021
Lua ATS, Action Tree Lua version.
View BaseClass.lua
function BaseClass(classname, super)
local cls
if super then
cls = {}
setmetatable(cls, {__index = super})
cls.super = super
else
cls = {ctor = function() end}
end
@yangfch3
yangfch3 / SAT.lua
Last active Sep 6, 2021
2D SAT 碰撞的 Lua 实现
View SAT.lua
local MathUtil = {}
---获取两点的距离
function MathUtil.GetDis(vec1, vec2)
local x1 = vec1.x or vec1[1]
local y1 = vec1.y or vec1[2]
local x2 = vec2.x or vec2[1]
local y2 = vec2.y or vec2[2]
local disX = x1 - x2
@yangfch3
yangfch3 / .eslintrc.vscode-plugin-global.js
Last active Jul 23, 2020
[eslint vscode 插件全局配置] #eslint #vscode
View .eslintrc.vscode-plugin-global.js
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
},
extends: ['eslint:recommended'],
globals: {
Atomics: 'readonly',
@yangfch3
yangfch3 / Layer.ts
Created Nov 8, 2018
[白鹭 Layer 管理组件] 用于方便地对进行 Layer 的管理 #白鹭 #游戏开发
View Layer.ts
class Layer extends egret.Sprite {
private mountTo: egret.DisplayObjectContainer
constructor(mountTo: LayersDisplayObjectContainer) {
super()
// Layer 挂载到的 UI
this.mountTo = mountTo
}
}
@yangfch3
yangfch3 / memoize.js
Last active Nov 2, 2018
[简易缓存机] 对一些方法/函数传参-返回值进行缓存 #设计模式 #utils
View memoize.js
// 对一个对象的方法做缓存
function Memoize(func, obj) {
obj = obj || window
func = obj[func]
let cache = {}
return function () {
let key = Array.prototype.join.call(arguments, '_')
if (!(key in cache)) {
// console.log('缓存未命中')
cache[key] = func.apply(obj, arguments)
@yangfch3
yangfch3 / bash-help.sh
Created Oct 10, 2018
[bash 速查手册] #bash #cheatsheets
View bash-help.sh
##############################################################################
# BASH CHEATSHEET (中文速查表) - by skywind (created on 2018/02/14)
# Version: 43, Last Modified: 2018/04/02 17:00
# https://github.com/skywind3000/awesome-cheatsheets
##############################################################################
##############################################################################
# 常用快捷键(默认使用 Emacs 键位)
##############################################################################
@yangfch3
yangfch3 / crawlDoubanBookInfo.js
Created Sep 13, 2018
[Chromeless 豆瓣数据抓取脚本] 以抓取一本书的猜你喜欢书籍列表信息为例 #crawl #douban
View crawlDoubanBookInfo.js
const {
Chromeless
} = require('chromeless')
const fs = require('fs')
const myConsole = console
const bookName = process.argv[2]
const bookInfoList = []
@yangfch3
yangfch3 / SoundManager.ts
Last active Nov 8, 2018
[白鹭声音管理器] 白鹭音频接口的封装 #白鹭 #游戏开发
View SoundManager.ts
class SoundManager {
private static instance: SoundManager
private static IS_MUTE_SYMBOL = 'isMute'
private static BGM_VOLUME = 'bgmVolume'
private static EFFECT_VOLUME = 'effectVolume'
static getInstance() {
if (!SoundManager.instance) {
new SoundManager()
@yangfch3
yangfch3 / cycle-await.js
Created Aug 18, 2018
循环与 async-await 搭配使用
View cycle-await.js
/**
* 并行阻塞:
* 一同等待
* 一起爆发式
*/
var arr = [1,2,3]
arr.forEach(async function (value, index) {
await new Promise((resolve, reject) => {
setTimeout(function () {
resolve(true)
@yangfch3
yangfch3 / SceneManager.ts
Last active Dec 30, 2019
[白鹭场景管理] 快捷有序地进行白鹭场景的管理 #白鹭 #游戏开发
View SceneManager.ts
///<reference path="./utils/array.ts" />
/**
* 控制场景的切换
* 与 Main 协同工作
*/
class SceneManager {
private static instance: SceneManager = null
static getInstance() {