【易次元2.0代碼參考】點(diǎn)擊式/隨機(jī)封面
//看清楚兩個(gè)不一樣的
//用到的變量(單張封面不需要用到這個(gè)變量)
var 隨機(jī)封面=0;
//綁定的事件(三種方式綁定事件是一樣的)
async function SJ_jinru() {
await ac.replaceUI({name: 'UI_jindu',uiId: '-gr_sad6',});
}
//單張封面
await ac.createImage({name: 'DT_fengmian',index: 1,inlayer: 'window',resId: '$50016217',pos: {x: 640,y: 360,},anchor: {x: 50,y: 50,},opacity: 100,visible: true,verticalFlip: false,horizontalFlip: false,dynaScale: 'cover',});
ac.addEventListener({type: ac.EVENT_TYPES.onTouchBegan,listener: SJ_jinru,target: 'DT_fengmian',});
//隨機(jī)封面多少只需要增加隨機(jī)范圍和條件數(shù)量即可
//隨機(jī)封面方式一
隨機(jī)封面= await ac.random({ min:1, max:5});
if (ac.var.隨機(jī)數(shù) === 1) {
await ac.createImage({name: 'DT_fengmian',index: 1,inlayer: 'window',resId: '$50016217',pos: {x: 640,y: 360,},anchor: {x: 50,y: 50,},opacity: 100,visible: true,verticalFlip: false,horizontalFlip: false,dynaScale: 'cover',});
} else if (ac.var.隨機(jī)數(shù) === 2) {
await ac.createImage({name: 'DT_fengmian',index: 1,inlayer: 'window',resId: '$50016217',pos: {x: 640,y: 360,},anchor: {x: 50,y: 50,},opacity: 100,visible: true,verticalFlip: false,horizontalFlip: false,dynaScale: 'cover',});
} else if (ac.var.隨機(jī)數(shù) === 3) {
await ac.createImage({name: 'DT_fengmian',index: 1,inlayer: 'window',resId: '$50016217',pos: {x: 640,y: 360,},anchor: {x: 50,y: 50,},opacity: 100,visible: true,verticalFlip: false,horizontalFlip: false,dynaScale: 'cover',});
} else if (ac.var.隨機(jī)數(shù) === 4) {
await ac.createImage({name: 'DT_fengmian',index: 1,inlayer: 'window',resId: '$50016217',pos: {x: 640,y: 360,},anchor: {x: 50,y: 50,},opacity: 100,visible: true,verticalFlip: false,horizontalFlip: false,dynaScale: 'cover',});
} else if (ac.var.隨機(jī)數(shù) === 5) {
await ac.createImage({name: 'DT_fengmian',index: 1,inlayer: 'window',resId: '$50016217',pos: {x: 640,y: 360,},anchor: {x: 50,y: 50,},opacity: 100,visible: true,verticalFlip: false,horizontalFlip: false,dynaScale: 'cover',});
}
ac.addEventListener({type: ac.EVENT_TYPES.onTouchBegan,listener: SJ_jinru,target: 'DT_fengmian',});
//隨機(jī)封面方式二
隨機(jī)封面= await ac.random({ min:1, max:5});
await ac.createPicDisplay({name: 'DT_fengmian',index: 1,inlayer: 'window',picGroup: [
{resId: '$50016217',condition: () => ac.var.隨機(jī)數(shù) === 1,clickFunc: SJ_jinru,},?
{resId: '$50016217',condition: () => ac.var.隨機(jī)數(shù) === 2,clickFunc: SJ_jinru,},?
{resId: '$50016217',condition: () => ac.var.隨機(jī)數(shù) === 3,clickFunc: SJ_jinru,},?
{resId: '$50016217',condition: () => ac.var.隨機(jī)數(shù) === 4,clickFunc: SJ_jinru,},?
{resId: '$50016217',condition: () => ac.var.隨機(jī)數(shù) === 5,clickFunc: SJ_jinru,},?
],pos: {x: 640,y: 360,},size: {width: 1920,height: 886,},anchor: {x: 50,y: 50,},opacity: 100,visible: true,verticalFlip: false,horizontalFlip: false,dynaScale: 'cover',});