@ debuffjp/ share (英语)
让你的游戏容易被传递:最后几秒钟的片段,系统共享表,以及"击败我的跑"挑战链接. 没有依赖关系,每个出口都可以自行使用.
import { ClipRecorder, challengeLink, clipFile, readChallenge, share } from "@debuffjp/share";
// A friend opened a challenge link: play their seed
const challenge = readChallenge<{ seed: number; score: number }>();
if (challenge) game.random.reseed(challenge.seed);
// Keep the last ~12 seconds while a run is going
const clips = new ClipRecorder(game.canvas, { seconds: 12 });
clips.start();
// On a "share" button (share needs a click or key press)
const clip = await clips.clip();
await share({
text: `I scored ${score}. Beat it?`,
url: challengeLink({ seed, score }),
files: clip ? [clipFile(clip, "my-run")] : [],
});
share()打开一个共享工作表,复制文本并链接其他内容。 它回来了"shared", (中文(简体) ),"copied", (中文(简体) ),"cancelled"或者说"unsupported"这样你就可以展示正确的祝酒词.ClipRecorder运行两个交错MediaRecorders,所以当运行开始而不是在页面负载上开始.ClipRecorder.supported()告诉你是否要显示剪辑按钮 .- 挑战数据可见于URL. 把游戏状态放进去 从不针对个人.
screenshot(canvas)财务报告和审定财务报表download(blob, name)覆盖"保存图像"按钮.postIntent({ text, url }, "x" | "bluesky")返回打开 X 或 Bluesky 作曲的链接,该链接带有已起草的后缀,切入以适应(X上280个加权字符,链接在 Bluesky 上为23,300个图表)。 什么也没有发布。 在您想要的地方使用它, 例如在 devlog 帖子的 dev 脚本中; debuff 从未将其添加到游戏中 。 增入0.26册.