lufy's legend

标题: 按钮点击区域Y轴偏离 [打印本页]

作者: jsjtzc    时间: 2022-2-4 08:26
标题: 按钮点击区域Y轴偏离
<header style="height:120px"></header>
<div id="content-main" class="flexcenter">                                <div id="content-body">                                                                        </div>                        </div>               


<script type="text/javascript">
                        let hHeight=document.getElementById('head').offsetHeight;
                        let wHeight=window.screen.height;
                        let wWidth=window.screen.width;
                        let sHtight=wHeight-hHeight
                        document.getElementById('content-body').style.height=sHtight+"px"
                        console.info(hHeight,wHeight);
                        let imgData=new Array();
                        LInit(1000/60,'content-body',wWidth,sHtight,main);
                        function main(){
                                //LGlobal.canvasObj.style.marginTop = hHeight+"px";
                                        // imgData.push({name:"stop_up",path:"./images/slot_stop_up.png"});

                                        // imgData.push({name:"stop_over",path:"./images/slot_stop_over.png"});

                                        imgData.push({name:"start",path:"images/Play.png"});
                                       
                                        imgData.push({name:"start2",path:"images/Play2.png"});

                                        imgData.push({name:"kake",path:"images/slot_kake.png"});

                                        // imgData.push({name:"slot_back",path:"./images/slot_back.jpg"});

                                        // imgData.push({name:"slot_ok",path:"./images/slot_ok.png"});

                                        imgData.push({name:"item1",path:"images/red_num_01.png"});

                                        imgData.push({name:"item2",path:"images/red_num_02.png"});

                                        imgData.push({name:"item3",path:"images/red_num_03.png"});

                                        imgData.push({name:"item4",path:"images/red_num_04.png"});

                                        imgData.push({name:"item5",path:"images/red_num_05.png"});


                                        loadingLayer = new LoadingSample1();
                                        addChild(loadingLayer);        
                                        LLoadManage.load(
                                                imgData,
                                                function(progress){
                                                        loadingLayer.setProgress(progress);
                                                },
                                                function(result){
                                                        imglist = result;
                                                        removeChild(loadingLayer);
                                                        loadingLayer = null;
                                                        gameInit();
                                                }
                                        );
                        }
                        function gameInit(event){
                                        let size=0.4
                                        let startLayer = new LSprite();
                                        addChild(startLayer);

                                        start = new LButton(new LBitmap(new LBitmapData(imglist["start"])),new LBitmap(new LBitmapData(imglist["start2"])));
                                        start.scaleX=size;
                                        start.scaleY=size;
                                        console.log(start.width)


                                        start.y = 400;

                                        startLayer.addChild(start);

                                        //start.addEventListener(LMouseEvent.MOUSE_UP, onmouseup);
                        }


作者: jsjtzc    时间: 2022-2-4 08:28
在网页是可以正常点击的,在手机APP上Y坐标会向上偏移
作者: jsjtzc    时间: 2022-2-4 08:34
Y轴偏移

作者: jsjtzc    时间: 2022-2-4 08:55
问题解决 用LGlobal.top=hHeight 修正偏移
作者: lufy    时间: 2022-2-7 12:33
jsjtzc 发表于 2022-2-4 08:55
问题解决 用LGlobal.top=hHeight 修正偏移

你是不是游戏画面在页面中间啊,引擎原则上不支持这样网页中只有一部分画面是canvas的情况
如果这种情况我大多推荐用ifame来解决
当然,如果你自己已经用其他方法搞定了的话也可以
作者: Ankit    时间: 2023-12-30 21:16
lufy 发表于 2022-2-7 12:33
你是不是游戏画面在页面中间啊,引擎原则上不支持这样网页中只有一部分画面是canvas的情况
如果这种情况 ...

Partial panel display may not be accepted by the engine in its entirety if your gaming screen is off-center on the webpage. As a solution, think about utilizing an iframe; otherwise, look into other ways to make changes on your own.




欢迎光临 lufy's legend (http://lufylegend.com/forum/) Powered by Discuz! X2.5