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