Git Product home page Git Product logo

minigame-canvas-engine's People

Contributors

pppro avatar yangbo1024 avatar yuanzm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minigame-canvas-engine's Issues

Github 与 Npm 的版本对应

请问下作者,该项目的 Github Master 分支已经是 1.0.6,而且我看 Github 也在频繁更新,但是 Npm 包已经好久没有更新过了,是有特定的分支与 Npm 包对应吗,请问该项目的更新策略是怎样的呢?

几个问题,麻烦看一下需要怎么解决

功能需求背景:
列表项可以点击展开详情,展开后列表项尺寸会变大,所需需要重新布局;且列表在有拖动位移之后展开,需要保持原列表滚动距离,比如当前显示第11-21名,展开后需要依然定位展示11-21名(此时21名可能只能展示一部分)。

1.getElementsById和getElementsByClassName对scrollview节点无效
2. 有的节点注册的事件无法生效,目前除了最外层节点都无法注册事件touchstart,click,touchend
3. 点击某项改变宽度,重新布局时会画面闪烁一下
4. 没有指定滑动列表位置(非初始0位置)的api

谢谢。

几个问题

  1. 调用init、layout之后就用代码调用scrollTo,实际没有滚动。
  2. 注册了click事件无法响应,但touchstart, touchend都可以响应;(isClick返回了false)
  3. 如果需要动态改变列表元素尺寸,则按现有使用逻辑应该是要先clear,再init+layout重新布局;这样的话,如果变动前列表有滚动位移,怎么才能定位到原位置(设置scrollTop和调用scrollTo都无效)?另外由于clear了,可能会看出画面闪烁。

测试代码:github中自带的cocoscreator的demo

display: none 属性支持

Layout.init阶段核心仅仅是根据xml和css创建了节点树,Layout.init之后是执行 Layout.layout执行渲染

之所以将 layout 单独抽象为一个函数,是因为 layout 应当是可以重复调用的,比如改变了一个元素的尺寸,实际上节点树是没变的,仅仅是需要重新计算布局,然后渲染

一个完整的 layout 分成下面的几步:

  1. 执行画布清理,因为布局变化页面需要重绘,这里没有做很高级的剔除等操作,一律清除重画,实际上性能已经很好;
  2. 节点树都含有 style 属性,css-layout 能够根据这些信息计算出最终布局,详情可见 https://www.npmjs.com/package/css-layout;
  3. 经过 Layout 计算,节点树带上了 layout、lastLayout、shouldUpdate 布局信息,但这些信息并不是能够直接用的比如 layout.top 是指在一个父容器内的 top,最终要实现渲染,实际上要递归加上父容器的 top这样每次 repaint 的时候只需要直接使用计算好的值即可,不需要每次都递归计算这一步称为 layoutChildren,目的在于将 css-layout 进一步处理为可以渲染直接用的布局信息;
  4. renderChildren:执行渲染;
  5. bindEvents:执行事件绑定;

其中步骤2 css-layout 并不会理解 display: none属性,要实现这个属性,应当是从节点树中临时剔除然后重新计算布局,同时要考虑 display: block 重置回去的场景。

目前能设置图片的z-index吗?

用来做微信小游戏的开放域,实现过程中发现图片的堆叠顺序可能是根据图片渲染完成的先后决定的,这就导致了背景图片可能遮盖前景图片和文字,想请问一下是否能够设置图片的z-index属性呢?

setfrienduserstorage: size of value exceed

我参考interactivedemo里面实现好友互动赠送的逻辑,我发现里面有句注释:

// 用户每天只能给同一个好友赠送一次金币,每天最多送5次

但是整个checkInteractiveData.js文件的上下文里面并没有次数的比较,所以这句注释让我觉得有点摸不着头脑,然后我在真机测试的时候,jsserver抛出错误setfrienduserstorage: size of value exceed

我想问,这个5次是微信的强制性校验吗,不需要我们写相关的逻辑的,如果是,那我们在开发阶段真机调试的时候超过了5次怎么办?以及如何解决jsserver抛出错误setfrienduserstorage: size of value exceed这个问题

scrollview无法滚动

编辑器代码如下
截屏2023-02-24 16 53 24

  <view class="container" id="main">
<scrollview class="list" scrollY="true">
        {{~it.data :item:index}}
            <view class="listItem">
              <text class="listItemNum" value="{{= index + 1}}"></text>
              <text class="listItemName" value="{{= item.nickname}}"></text>
              <text class="listItemScore" value="{{= item.rankScore}}"></text>
            </view>
        {{~}}
    </scrollview>
<view class="selfListItem">
        <text class="listItemScore" value="{{= item.rankScore}}"></text>
        <text class="listItemName" value="{{= it.self.nickname}}"></text>
        <text class="listItemNum" value="{{= it.selfIndex}}"></text>
    </view> 
</view>


window.styleValue = {
 container: {
    width: 375,
    height: 812,
  	alignItems:'center',
},

list: {
    width          : 263,
    height         : 262,     
},

listItem: {
    width: 263,
    height: 64,
    flexDirection: 'row',
    alignItems: 'center',
  	backgroundColor:'rgba(166, 96, 255, 1)',
  	borderBottomWidth:1,
  	borderColor:'rgba(255, 255, 255, 0.1)',
},

listItemNum: {
  	width:40,
  	marginLeft:8,
    fontSize: 16,
    fontWeight: 'bold',
color:'#ffffff',
  	textAlign:'center',
},	


listItemScore: {
    fontSize: 16,
  	color:'#ffffff',
    textAlign: 'right',
  	flex:1,
  	marginRight:8,
},

listItemName:{
    fontSize: 16,
    fontWeight: 'bold',
color:'#ffffff',
  	marginLeft:32,
},

selfListItem: {
  	width:335,
  	height:66,
   	borderRadius: 4,
  	borderWidth: 2,
  	borderColor: '#ffffff',
   	flexDirection: 'row',
    alignItems: 'center',
    },
}

/**
  * xml为编辑器实例,挂载到window对象,通过xml.getValue可以拿到模板字符串
  * style为编辑器实例,挂载到window对象,通过style.getValue可以拿到样式对象的字符串值
  * 控制台默认
  */
let xmlValue   = window.xml.getValue();
let styleValue = window.style.getValue();
let styleObj = eval(styleValue);

// 创建mock数据
let item = {
  nickname: "zim",
  rankScore: 1,
  avatarUrl: 'https://res.wx.qq.com/wechatgame/product/webpack/userupload/20191119/wegoing.jpeg',
};
let datasource =  {
  data     :[],
  selfIndex: 1,
  self     : item
}
for ( let i = 0; i < 20;i++ ) {
  var cp = JSON.parse(JSON.stringify(item));
  cp.rankScore = Math.floor(Math.random()*1000+1)
  datasource.data.push(cp);
}

// 将XML模板编译成XML字符串
let tempFn     = window.doT.template(xmlValue);
let resultText = tempFn(datasource);

function init() {
// getElementPagePosition为IDE内置函数
    let pos = window.getElementPagePosition(canvas);
    // 每次初始化之前先执行清理逻辑保证内存不会一直增长
    Layout.clear();
    // 初始化引擎
    Layout.init(resultText, styleObj);

// 设置canvas的尺寸和样式的container比例一致
    canvas.width = 375;
    canvas.height = 812;
    canvas.style.width =  '375px';
    canvas.style.height = '812px';

    Layout.updateViewPort({
      x     : 0,
      y     : 0,
      width : 375,
      height: 812,
    });

    Layout.layout(context);
  }

 init();
 window.onresize = init;

使用minigame-unity-webgl-transform项目转的微信小游戏该如何使用此引擎

在unity中调用了js的openPage方法(模仿微信UnitySDK中调用js的方式), 然后我想在js中绘制一个简单的页面
核心代码如下

const template = `  <view id="container">
    <text id="testText" class="redText" value="hello canvas"></text>
  </view>`;
const style = {
  container: {
    width: 800,
    height: 400,
    backgroundColor: '#f3f3f3',
    justifyContent: 'center',
    alignItems: 'center',
  },
  testText: {
    color: '#ffffff',
    width: '100%',
    height: '100%',
    lineHeight: 400,
    fontSize: 80,
    textAlign: 'center',
  },
  // 文字的最终颜色为#ff0000
  redText: {
    color: '#ff0000',
  }
}
// 绘制一个页面
export function openPage() {
    let canvas = wx.createCanvas();
    let context = canvas.getContext('2d');
    Layout.init(template, style);
    Layout.updateViewPort(canvas.getBoundingClientRect());
    Layout.layout(context);
}

预期效果
可以在游戏的画面上渲染出 hello canvas 的文字

实际效果
代码没有报错也没有任何效果

请问我如何才能实现我想要的效果(核心需求就是想在游戏unity外去绘制一个界面) 或者可以给个配合minigame-unity-webgl-transform使用的例子

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.