diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js index a004c5dac6..39910567d2 100644 --- a/cocos2d/core/CCGame.js +++ b/cocos2d/core/CCGame.js @@ -693,6 +693,7 @@ var game = { = cc.create3DContext(localCanvas, { 'stencil': true, 'alpha': cc.macro.ENABLE_TRANSPARENT_CANVAS, + 'antialias': cc.macro.ENABLE_WEBGL_ANTIALIAS }); } // WebGL context created successfully diff --git a/cocos2d/core/load-pipeline/loader.js b/cocos2d/core/load-pipeline/loader.js index 595e7c0b87..69acbf8ac2 100644 --- a/cocos2d/core/load-pipeline/loader.js +++ b/cocos2d/core/load-pipeline/loader.js @@ -56,10 +56,6 @@ function loadImage (item, callback) { tex.url = rawUrl; tex.initWithElement(item.content); tex.handleLoadedTexture(); - if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) { - // Image element no longer needed - misc.imagePool.put(item.content); - } cc.textureCache.cacheImage(rawUrl, tex); return tex; } diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index cec60923da..ecedc15121 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -1915,6 +1915,22 @@ cc.macro = { * @default false */ ENABLE_TRANSPARENT_CANVAS: false, + + /** + * !#en + * Boolean that indicates if the WebGL context is created with `antialias` option turned on, + * default value is true, most game need it for the picture to eliminate the hard edges, + * but in some case, if you are trying to apply pixel art or using tilemaps, then you may need to turn it off. + * You can set it to false before `cc.game.run`. + * Web only. + * !#zh + * 用于设置在创建 WebGL Context 时是否开启 `antialias` 选项,默认值是 true,大多数游戏都更适合这样的效果, + * 但是如果你需要实现像素风格,或是使用 Tiledmap,那么你可能需要手动设置这个值为 false,你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + * 仅支持 Web + * @property {Boolean} ENABLE_WEBGL_ANTIALIAS + * @default true + */ + ENABLE_WEBGL_ANTIALIAS: true }; /** diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index e0eb73b367..dfdf36f4a3 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -890,7 +890,6 @@ game.once(game.EVENT_RENDERER_INITED, function () { opts.minFilter = opts.magFilter = filter; this.update(opts); - this._image = null; this.loaded = true; this.emit("load"); }; diff --git a/cocos2d/tilemap/CCSGTMXLayer.js b/cocos2d/tilemap/CCSGTMXLayer.js index a84c652ce9..53e8a5865f 100644 --- a/cocos2d/tilemap/CCSGTMXLayer.js +++ b/cocos2d/tilemap/CCSGTMXLayer.js @@ -209,8 +209,9 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{ this._texGrids = []; for (i = 0; i < len; ++i) { tileset = tilesets[i]; - tex = cc.textureCache.addImage(tileset.sourceImage); - tex.setAliasTexParameters(); + tex = cc.textureCache.addImage(tileset.sourceImage, function (tex) { + tex.setAliasTexParameters(); + }); this._textures[i] = tex; this._fillTextureGrids(tileset, i); if (tileset === tilesetInfo) {