textureCache 类型

模块: cc 父模块: cc

cc.textureCache is a singleton object, it's the global cache for cc.Texture2D

索引

方法
  • description Description
  • textureForKey Returns an already created texture. Returns null if the texture doesn't exist.
  • getTextureForKey Returns an already created texture. Returns null if the texture doesn't exist.
  • getTextureColors
  • getAllTextures 获取所有贴图
  • removeAllTextures

    Purges the dictionary of loaded textures.
    Call this method if you receive the "Memory Warning"
    In the short term: it will free some resources preventing your app from being killed
    In the medium term: it will allocate more resources
    In the long term: it will be the same

  • removeTexture Deletes a texture from the cache given a texture.
  • removeTextureForKey Deletes a texture from the cache given a its key name.
  • addImage

    Returns a Texture2D object given an file image
    If the file image was not previously loaded, it will create a new Texture2D
    object and it will return it. It will use the filename as a key.
    Otherwise it will return a reference of a previously loaded image.
    Supported image extensions: .png, .jpg, .gif

  • cacheImage Cache the image data.

Details

方法

description

Description

meta description
返回 String
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:44
textureForKey

Returns an already created texture. Returns null if the texture doesn't exist.

meta description
返回 Texture2D | Null
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:53
参数列表
示例
------------------
var key = cc.textureCache.textureForKey("hello.png");
getTextureForKey

Returns an already created texture. Returns null if the texture doesn't exist.

meta description
返回 Texture2D | Null
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:66
参数列表
示例
------------------
var key = cc.textureCache.getTextureForKey("hello.png");
getTextureColors
meta description
返回 Array
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:96
参数列表
  • texture HTMLImageElement
示例
---------------
var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
getAllTextures

获取所有贴图

meta description
返回 Texture2D[]
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:117
removeAllTextures

Purges the dictionary of loaded textures.
Call this method if you receive the "Memory Warning"
In the short term: it will free some resources preventing your app from being killed
In the medium term: it will allocate more resources
In the long term: it will be the same

meta description
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:132
示例
--------
cc.textureCache.removeAllTextures();
removeTexture

Deletes a texture from the cache given a texture.

meta description
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:150
参数列表
  • texture HTMLImageElement
示例
-----
cc.textureCache.removeTexture(texture);
removeTextureForKey

Deletes a texture from the cache given a its key name.

meta description
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:169
参数列表
示例
------
cc.textureCache.removeTexture("hello.png");
addImage

Returns a Texture2D object given an file image
If the file image was not previously loaded, it will create a new Texture2D
object and it will return it. It will use the filename as a key.
Otherwise it will return a reference of a previously loaded image.
Supported image extensions: .png, .jpg, .gif

meta description
返回 Texture2D
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:185
参数列表
示例
----
cc.textureCache.addImage("hello.png");
cacheImage

Cache the image data.

meta description
定义于 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/textures/CCTextureCache.js:201
参数列表
  • path String
  • texture HTMLImageElement | HTMLCanvasElement

results matching ""

    No results matching ""