Cocos2d HTML call Jquery-qrcode generated two-dimensional code __html

Source: Internet
Author: User

Today encountered a problem, in the game needs to be based on parameters to generate a different two-dimensional code, a pass after Baidu finally solved the problem (do not know whether there are better methods, but also hope to inform).

1. Use Jquery-qrcode to generate two-dimensional code and transform it into image data:

  <script src= ' js/jquery-1.8.0.min.js ' type= ' text/javascript ' ></script>
  <script src= ' js/ Jquery.qrcode.min.js ' type= ' text/javascript ' ></script>
  <script type= ' Text/javascript ' >
      $ ( ' #qrcode '). QRCode ({width:320,height:320,text: "Http://www.zhai100.net"});
      var $code = $ (' #qrcode > Canvas ');
      var codeData = $code [0].todataurl ();
  </script>

2. Use Cc.loader to load pictures and display

var self = this;
CC.LOADER.LOADIMG (Gcodedata, {iscrossorigin:false}, Function (Err, img) {
    var texture2d =  New CC. Texture2d ();
    Texture2d.initwithelement (IMG);
    Texture2d.handleloadedtexture ();

    var Erweima = new CC. Sprite (texture2d);
    erweima.x = SELF.QRCODESPRITE.WIDTH/2;
    ERWEIMA.Y = SELF.QRCODESPRITE.HEIGHT/2;
    Self.addchild (Erweima,);

COCOS2D HTML to load network pictures, you can also refer to similar ideas.

Source: Https://github.com/longwenjunjie/cocos2d-html-qrcode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.