当前位置: 首页 > news >正文

AnimateCC基础教学:漫天繁星-由DeepSeek辅助完成

1.界面及元件抓图:

2.核心代码:

// 初始化设置
var stars = [];
var stars2 = [];
var numStars = 100;
var stageWidth = stage.canvas.width;
var stageHeight = stage.canvas.height;
console.log(stageWidth, stageHeight);// 创建星星函数
function createStar() {var star = new lib.starlink(); // 使用库中的Star元件	star.x = Math.random() * stageWidth;star.y = Math.random() * stageHeight;star.alpha = Math.random() * 0.5 + 0.5; // 初始透明度star.scaleX = star.scaleY = Math.random() * 0.05 + 0.1; // 随机大小// 添加闪烁动画createjs.Tween.get(star, {loop: true}).to({alpha: 0}, Math.random() * 1000 + 500).to({alpha: 1}, Math.random() * 1000 + 500);return star;
}function createStar2() {var star2 = new lib.star2link(); // 使用库中的Star元件	star2.x = Math.random() * stageWidth;star2.y = Math.random() * stageHeight;star2.alpha = Math.random() * 0.5 + 0.5; // 初始透明度star2.scaleX = star2.scaleY = Math.random() * 0.05 + 0.1; // 随机大小// 添加闪烁动画createjs.Tween.get(star2, {loop: true}).to({alpha: 0}, Math.random() * 1000 + 500).to({alpha: 1}, Math.random() * 1000 + 500);return star2;
}// 创建多个星星
for (var i = 0; i < numStars; i++) {var star = createStar();stars.push(star);stage.addChild(star);var star2 = createStar2();stars2.push(star2);stage.addChild(star2);
}// 更新舞台
stage.update();// 启用动画更新
/*createjs.Ticker.timingMode = createjs.Ticker.RAF;
createjs.Ticker.addEventListener("tick", function () {stage.update();
});*/

相关文章:

  • day31 第八章 贪心算法 part05
  • 生活需要一些思考
  • ppt箭头素材图片大全
  • 如何提升自我价值?
  • std::string的底层实现 (详解)
  • [4-06-09].第10节:自动配置- 分析@SpringBootApplication启动类
  • 防爆风扇储能轴流风机风量风压如何保障通风安全?
  • java每日精进 4.29【框架之自动记录日志并插入如数据库流程分析】
  • Lucene 分词工具全解析与对比指南
  • Spring AI在大模型领域的趋势场景题深度解析
  • 网络原理 - 11(HTTP/HTTPS - 2 - 请求)
  • Shopify网上商店GraphQL Admin接口查询实战
  • idm 禁止自动更新提示(修改注册表)
  • Spring MVC中自定义日期类型格式转换器
  • 精益数据分析(32/126):电商指标优化与搜索策略解析
  • 【Python笔记 05】 if判断、比较运算符与逻辑运算符
  • Linux Ollama离线安装/更新教程-适用于国内快速下载Ollama最新版本(亲测好用)--适用于Qwen3 系列模型
  • 2025年- H12-Lc119-56.合并区间(普通数组)---java版
  • ROS2 学习
  • Uniapp:置顶
  • 黄宾虹诞辰160周年|一次宾翁精品的大集结
  • 解放日报社论:只争朝夕、不负重托,加快建成具有全球影响力的科技创新高地
  • 民生银行一季度净利127.42亿降逾5%,营收增7.41%
  • 国家核准10台核电新机组,四大核电央企披露新项目进展
  • 国务院任免国家工作人员:饶权任国家文物局局长
  • 最近这75年,谁建造了上海?