cocos2d js编译
cocos compile -p web -m release -sC:\Users\Ziyi\Documents\www\cocos2d\pro1
target.removeTouchEventListenser is not a function
正确写法 target.removeTouchEventListenser;
cc.director.replaceScene is not a function
coocs2d-js 3.x 之后场景切换用的是 cc.director.runScene
cocos2d-js 创建新工程
// 创建一个包含 Cocos2d-x JSB 和 Cocos2d-html5 工程: cocos new -l js // 创建一个仅包含 Cocos2d-html5 的工程: cocos new -l js --no-native // 在指定的目录创建一个指定名字的工程: cocos new projectName -l js -d ./Projects 正常使用: cocos new projectName -l js --no-native -d ./Projects
js中的this关键字详解
this是Javascript语言的一个关键字。它代表函数运行时,自动生成的一个内部对象,只能在函数内部使用 随着函数使用场合的不同,this的值会发生变化。但是有一个总的原则,那就是this指的是,调用函数的那个对象。 情况一:纯粹的函数调用 这是函数的最通常用法,属于全局性调用,因此this就代表全局对象Global。 function test(){ this.x = 1; alert(this.x); } test(); // 1 为了证明this就是全局对象,我对代码做一些改变: var x = 1; function test(){ alert(this.x); } test(); // 1 运行结果还是1。再变一下: var x = 1; function test(){ this.x = 0; } test(); alert(x); //0 情况二:作为对象方法的调用 函数还可以作为某个对象的方法调用,这时this就指这个上级对象。 function test(){...
JS的构造函数
原文地址:http://www.cnblogs.com/jikey/archive/2011/05/13/2045005.html //构造函数//使自己的对象多次复制,同时实例根据设置的访问等级可以访问其内部的属性和方法//当对象被实例化后,构造函数会立即执行它所包含的任何代码function myObject(msg){//特权属性(公有属性)this.myMsg = msg; //只在被实例化后的实例中可调用this.address = ‘上海’; //私有属性var name = ‘豪情’;var age = 29;var that = this; //私有方法function sayName(){alert(that.name);}//特权方法(公有方法)//能被外部公开访问//这个方法每次实例化都要重新构造而prototy...
PHP获取文件大小
这两天做了个把图片转为base64传到服务器后,想限制图片大小, 可以用strlen测量传回来的字符串长度,基本上即为图片大小 bit 乘以1024即为byte 注意这里使用strlen而不是sizeof sizeof() 函数计算 数组中元素数目 或 对象中的 属性个数。
js获取当前域名
<script language=”javascript”>//获取域名host = window.location.host;host2=document.domain; //获取页面完整地址url = window.location.href; document.write(“<br>host=”+host)document.write(“<br>host2=”+host2)document.write(“<br>url=”+url)</script>
php gd库 imagettftext
array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile ,string $text ) image An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(). size The font size. Depending on your version of GD, this should be specified as the pixel size (GD1) or point size (GD2). angle The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For e...
微信 drawImage
[pcsh lang=”js” tab_size=”4” message=”” hl_lines=”” provider=”manual”] function getimgbase64(file){ var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); canvas.width = canvaswidth; canvas.height = canvasheight; var x=$('#make-photo .theme').children('.photo').css('left').split('px')[0]; var img = new Image(); function tmpLoad() { x = x > 0 ? x : -x; ctx.drawImage(im...