Commit dcf9e079 authored by spc's avatar spc
parents 59121ce6 ff434fd6
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- <script-->
<!-- src="https://yun.duiba.com.cn/polaris/zepto.min.f5f743714a5ee209f7451ba74d0ce24dbefb1d27.js"-->
<!-- crossorigin="anonymous"-->
<!-- ></script>-->
<style>
#canvas {
width: 750px;
height: 500px;
background: rebeccapurple;
}
.arr {
margin-left: 20rpx;
height: 34rpx;
border-radius: 34rpx;
padding: 10rpx 20rpx;
font-size: 29rpx;
color: #7f4613;
line-height: 32rpx;
white-space: nowrap;
animation: marquee 8s linear;
font-family: "xyjx";
background-color: #a2847e;
transform-origin: right center;
}
.private {
margin-left: 20rpx;
border-radius: 34rpx;
padding: 10rpx 20rpx;
font-size: 29rpx;
color: #c3821e;
line-height: 32rpx;
white-space: nowrap;
animation: marquee 8s linear;
font-family: "xyjx";
background-color: rgba(255, 255, 255, 1);
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
/**
* @type {HTMLCanvasElement}
*/
const canvas = document.getElementById("canvas");
canvas.width = 750 * window.devicePixelRatio;
canvas.height = 500 * window.devicePixelRatio;
class Item {
txt = "";
x = 750 + 50; // 从右侧开始
y = 0; // y坐标
width = 0;
speed = 2; // 移动速度
height = 34; // 弹幕高度
ctx = null;
isPrivate = false;
constructor(ctx, text, track, isPrivate = false) {
this.ctx = ctx;
this.txt = text;
this.width = ctx.measureText(text).width;
// 根据轨道号计算y坐标
const trackSpacing = 60; // 轨道间距
const startY = 50; // 第一个轨道的y坐标
this.y = startY + (track * trackSpacing); // 根据轨道计算具体y坐标
this.isPrivate = isPrivate;
}
update = () => {
this.x -= this.speed;
return (this.x + this.width + 50) < 0; // 返回true表示弹幕已经完全移出屏幕
};
draw = () => {
this.ctx.font = '29px xyjx'; // 使用相同的字体和大小
// 计算背景矩形的尺寸
const padding = 20; // 对应 padding: 10rpx 20rpx
const height = 34; // 对应 height: 34rpx
// 绘制圆角矩形背景
if (this.isPrivate) {
this.ctx.fillStyle = '#ffffff';
} else {
this.ctx.fillStyle = '#a2847e';
}
this.roundRect(
this.x - padding,
this.y - height / 1.2, // 调整垂直位置使文字居中
this.width + padding * 2,
height,
height / 2 // 圆角半径 = 高度的一半,实现 border-radius: 34rpx
);
// 绘制文字
if (this.isPrivate) {
this.ctx.fillStyle = '#c3821e';
} else {
this.ctx.fillStyle = '#7f4613';
}
this.ctx.fillText(this.txt, this.x, this.y);
};
// 辅助方法:绘制圆角矩形
roundRect = (x, y, width, height, radius) => {
this.ctx.beginPath();
this.ctx.moveTo(x + radius, y);
this.ctx.lineTo(x + width - radius, y);
this.ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
this.ctx.lineTo(x + width, y + height - radius);
this.ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.ctx.lineTo(x + radius, y + height);
this.ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
this.ctx.lineTo(x, y + radius);
this.ctx.quadraticCurveTo(x, y, x + radius, y);
this.ctx.closePath();
this.ctx.fill();
};
}
class ItemTrack {
textArr = [];
textIndex = 0;
trackArr = [];
itemArr = [];
trackStatus = [0, 0, 0, 0, 0, 0]; // 六个轨道的状态
minDistance = 150; // 增加最小间距
canvas = null;
ctx = null;
constructor(canvas, textArr, trackNum = 6) {
this.textArr = textArr;
this.canvas = canvas;
this.ctx = canvas.getContext("2d");
this.ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
this.ctx.font = "29px xyjx";
this.textArr = textArr.sort((a, b) => Math.random() - 0.5);
for (let i = 0; i < trackNum; i++) {
this.trackArr.push([]);
}
this.timer = setInterval(() => {
// 寻找可用的轨道
const availableTrack = this.findAvailableTrack();
if (availableTrack !== -1) {
const text = this.textArr[this.textIndex % this.textArr.length];
this.textIndex++;
this.trackArr[availableTrack].push(new Item(this.ctx, text.content, availableTrack, text.isPrivate));
}
}, 1000);
this.loop();
}
loop = () => {
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.draw();
requestAnimationFrame(this.loop);
}
// 找到一个可用的轨道
findAvailableTrack = () => {
const tracks = this.trackArr.map((_, index) => index);
// 随机打乱轨道顺序,使弹幕出现更随机
const shuffledTracks = tracks.sort(() => Math.random() - 0.5);
for (const track of shuffledTracks) {
// 找到当前轨道上的所有弹幕
const itemsInTrack = this.trackArr[track].filter((item) => {
const trackY = 50 + track * 60;
return Math.abs(item.y - trackY) < 1;
});
if (itemsInTrack.length === 0) {
return track; // 轨道完全空闲
}
// 获取该轨道最后一个弹幕
const lastItem = itemsInTrack[itemsInTrack.length - 1];
// 检查最后一个弹幕是否已经足够远
if (750 - (lastItem.x + lastItem.width) >= this.minDistance) {
return track;
}
}
return -1; // 所有轨道都不可用
}
draw = () => {
this.trackArr.forEach((track, index) => {
this.trackArr[index] = track.filter((item) => {
const shouldKeep = !item.update();
if (shouldKeep) {
item.draw();
}
return shouldKeep;
});
});
// 调试用:显示轨道位置
this.drawTrackLines();
}
// 调试用:显示轨道位置
drawTrackLines = () => {
this.ctx.strokeStyle = 'rgba(255,255,255,0.2)';
for (let i = 0; i < 6; i++) {
const y = 50 + i * 60;
this.ctx.beginPath();
this.ctx.moveTo(0, y);
this.ctx.lineTo(750, y);
this.ctx.stroke();
}
}
}
const itemTrack = new ItemTrack(canvas, [
{
content: '会员23123: 变美体验之旅-享毛戈平明星化妆师勋勋全国',
isPrivate: false
},
{
content: '会员23123: 黑金之旅-护肤体验大全套',
isPrivate: true
},
{
content: '11esse irure est',
isPrivate: false
},
{
content: '8888esse irure est',
isPrivate: false
},
{
content: 'Hello',
isPrivate: false
},
]);
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.0",
"importer": "*",
"imported": true,
"uuid": "cdfd993d-77ef-42a9-a643-e959ebe14f9b",
"files": [
".json",
".svga"
],
"subMetas": {},
"userData": {}
}
This diff is collapsed.
......@@ -27,6 +27,7 @@ export default class GameRevivePanel extends Panel {
clickFlag: boolean = false;
isClickShare: boolean = false;
isReview: boolean = false;
onLoad() {
this.cardRevive.on(Button.EventType.CLICK, this.clickCard, this);
......@@ -42,10 +43,9 @@ export default class GameRevivePanel extends Panel {
}
onPageVisibility = (visible) => {
if (visible && this.isClickShare) {
if (visible && this.isClickShare && !this.isReview) {
hideShareGuide();
this.hidePanel();
MainGame.ins.review();
this.review(3);
}
};
......@@ -97,13 +97,15 @@ export default class GameRevivePanel extends Panel {
}
async review(type: 1 | 2 | 3, ticket?: string) {
if (this.isReview) return;
this.isReview = true;
const param: any = {
type,
startId: gameStore.startInfo.startId,
};
if (type == 1) {
param.ticket = ticket;
param.ticketNum = ticket;
}
const { success } = await sendWebNetWithToken(WebNetName.reviveGame, param);
......
......@@ -190,7 +190,15 @@ export class BlessingBagPage extends Scene {
const EarnList = instantiate(this.earn_list)
this.content.addChild(EarnList)
const Label_task_name = EarnList.getChildByName("Label_task_name")
Label_task_name.getComponent(Label).string = `${item.title}(${item.completedSize}/${item.intervalLimitSize})`
if (item.code == "task_invite"){
Label_task_name.getComponent(Label).string = item.title
}else{
Label_task_name.getComponent(Label).string = `${item.title}(${item.completedSize}/${item.intervalLimitSize})`
}
const bag_num = EarnList.getChildByName("bag_num")
bag_num.getComponent(Label).string = item.subTitle
......@@ -280,7 +288,7 @@ export class BlessingBagPage extends Scene {
if (this.bagInfo.remainBagSilverNum < 1) {
showToast("福袋数量不足")
} else {
showPanel(OpenLuckyPanel, { num: 1, type: "sliver" });
showPanel(OpenLuckyPanel, {num: 1, type: "sliver"});
}
}
......@@ -289,7 +297,7 @@ export class BlessingBagPage extends Scene {
if (this.bagInfo.remainBagSilverNum < 5) {
showToast("福袋数量不足")
} else {
showPanel(OpenLuckyPanel, { num: 5, type: "sliver" });
showPanel(OpenLuckyPanel, {num: 5, type: "sliver"});
}
}
......@@ -298,7 +306,7 @@ export class BlessingBagPage extends Scene {
if (this.bagInfo.remainBagSilverNum < this.bagInfo.bagSilverToGold) {
showToast("福袋数量不足")
} else {
showPanel(OpenLuckyPanel, { num: 1, type: "gold" })
showPanel(OpenLuckyPanel, {num: 1, type: "gold"})
}
}
......@@ -307,7 +315,7 @@ export class BlessingBagPage extends Scene {
if (this.bagInfo.remainBagSilverNum < this.bagInfo.bagSilverToGold * 5) {
showToast("福袋数量不足")
} else {
showPanel(OpenLuckyPanel, { num: 5, type: "gold" })
showPanel(OpenLuckyPanel, {num: 5, type: "gold"})
}
}
......@@ -316,7 +324,7 @@ export class BlessingBagPage extends Scene {
if (this.bagInfo.remainBagSilverNum < this.bagInfo.bagSilverToDiamond) {
showToast("福袋数量不足")
} else {
showPanel(OpenLuckyPanel, { num: 1, type: "diamond" });
showPanel(OpenLuckyPanel, {num: 1, type: "diamond"});
}
}
......@@ -325,7 +333,7 @@ export class BlessingBagPage extends Scene {
if (this.bagInfo.remainBagSilverNum < this.bagInfo.bagSilverToDiamond * 5) {
showToast("福袋数量不足")
} else {
showPanel(OpenLuckyPanel, { num: 5, type: "diamond" });
showPanel(OpenLuckyPanel, {num: 5, type: "diamond"});
}
}
......@@ -333,9 +341,9 @@ export class BlessingBagPage extends Scene {
//去赚福袋任务
async clickTofinish(taskId, taskCode, jumpUrl) {
if(taskCode == "task_invite"){
if (taskCode == "task_invite") {
shareStore.doShare();
}else{
} else {
// const {success, data} = await sendWebNetWithToken(WebNetName.finishTask, {taskId, taskCode})
// if (!success) return
window.location.href = jumpUrl
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>零食贪吃蛇</title>
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
<meta name="viewport"
content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1,minimal-ui=true" />
<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=no">
<!-- force webkit on 360 -->
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<!-- force edge on IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="msapplication-tap-highlight" content="no">
<!-- force full screen on some browser -->
<meta name="full-screen" content="yes" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<!--fix fireball/issues/3568 -->
<!--<meta name="browsermode" content="application">-->
<meta name="x5-page-mode" content="app">
<!--<link rel="apple-touch-icon" href=".png" />-->
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
<style>
html {
-ms-touch-action: none;
}
body, canvas, div {
display: block;
outline: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
/* Remove spin of input type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
/* display: none; <- Crashes Chrome on hover */
-webkit-appearance: none;
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}
body {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 0;
border: 0;
margin: 0;
cursor: default;
color: #888;
background-color: white;
text-align: center;
font-family: Helvetica, Verdana, Arial, sans-serif;
display: flex;
flex-direction: column;
}
canvas {
background-color: rgba(0, 0, 0, 0);
}
#GameDiv, #Cocos3dGameContainer, #GameCanvas {
width: 100%;
height: 100%;
}
:root {
--safe-top: env(safe-area-inset-top);
--safe-right: env(safe-area-inset-right);
--safe-bottom: env(safe-area-inset-bottom);
--safe-left: env(safe-area-inset-left);
}
</style>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/assets/plugin/zepto.min.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/assets/plugin/declare-process.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/assets/plugin/SVGA.Lite.v2.1.1.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/assets/plugin/jszip.min.v3.10.1.js"></script>
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/assets/plugin/rem.min.js"></script>
<script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/style.css" />-->
<!-- <link rel="stylesheet" type="text/css" href="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/custom.css" />-->
<!-- <script src="//yun-duiba-credits-test.duibatest.com.cn/TNGD_GAMES/libs/eruda.min.js"></script>-->
<!-- <script>eruda.init()</script>-->
</head>
<body style="overflow: hidden;">
<div id="GameDiv" cc_exact_fit_screen="true" style="overflow: hidden;">
<div id="Cocos3dGameContainer">
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="99"></canvas>
</div>
</div>
<!-- Polyfills bundle. -->
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/polyfills.bundle.js" charset="utf-8"></script>
<!-- SystemJS support. -->
<script src="//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/system.bundle.js" charset="utf-8"></script>
<!-- Import map -->
<!--<script src="https://yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/src/import-map.json" type="systemjs-importmap" charset="utf-8"></script>-->
<script type="systemjs-importmap" charset="utf-8">
{"imports":{"cc":"//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/cocos-js/cc.js"}}
</script>
<script>
System.import('//yun.duiba.com.cn/db_games/ccc_game/template3d/1733919216581/index.js').catch(function (err) {
console.error(err);
})
</script>
</body>
</html>
......@@ -42,11 +42,11 @@
"1730878748609": {
"type": "build",
"id": "1730878748609",
"progress": 1,
"state": "success",
"progress": 0.2090909090909091,
"state": "processing",
"stage": "build",
"message": "2024-12-11 20:14:51 build success in 1 min 14 s!",
"detailMessage": "builder:build-project-total (74330ms)\r",
"message": "Build script in bundle start",
"detailMessage": "Run build task(build-script) in child, see: chrome://inspect/#devices\r",
"options": {
"name": "cocos-template-3d",
"server": "",
......@@ -109,7 +109,7 @@
"__version__": "1.3.8",
"logDest": "project://temp/builder/log/web-mobile2024-11-6 15-39.log"
},
"time": "2024-12-11 20:13:36",
"time": "2024-12-12 10:30:55",
"dirty": false
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment