Class Index | File Index

Classes


Class cc.RenderTexture


Extends cc.Node.

Defined in: CCRenderTexture.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
cc.RenderTexture is a generic rendering target.
Field Summary
Field Attributes Field Name and Description
 
the offscreen canvas for rendering and storing the texture
 
stores a reference to the canvas context object
Method Summary
Method Attributes Method Name and Description
 
starts grabbing
 
beginWithClear(r, g, b, depthValue, stencilValue, a)
starts rendering to the texture while clearing the texture first.
 
clear(r, g, b, a)
clears the texture with a color
 
clears the texture with a specified depth value
 
clearStencil(stencilValue)
clears the texture with a specified stencil value
<static>  
cc.RenderTexture.create(width, height, format, depthStencilFormat)
creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
 
ctor()
Constructor
 
end()
ends grabbing
 
 
The sprite
 
initWithWidthAndHeight(width, height, format, depthStencilFormat)
 
Listen "come to background" message, and save render texture.
 
creates a new CCImage from with the texture's data.
 
saveToFile(filePath, format)
saves the texture into a file using JPEG format.
 
 
setSprite(sprite)
Methods borrowed from class cc.Node:
addChild, cleanup, convertToNodeSpace, convertToNodeSpaceAR, convertTouchToNodeSpace, convertTouchToNodeSpaceAR, convertToWorldSpace, convertToWorldSpaceAR, description, draw, getActionByTag, getActionManager, getAnchorPoint, getAnchorPointInPoints, getBoundingBox, getBoundingBoxToWorld, getCamera, getChildByTag, getChildren, getChildrenCount, getContentSize, getGLServerState, getGrid, getOrderOfArrival, getParent, getPosition, getPositionX, getPositionY, getRotation, getScale, getScaleX, getScaleY, getScheduler, getShaderProgram, getSkewX, getSkewY, getTag, getUserData, getUserObject, getVertexZ, getZOrder, ignoreAnchorPointForPosition, init, isIgnoreAnchorPointForPosition, isRunning, isVisible, nodeToParentTransform, nodeToWorldTransform, numberOfRunningActions, onEnter, onEnterTransitionDidFinish, onExit, onExitTransitionDidStart, parentToNodeTransform, pauseSchedulerAndActions, release, removeAllChildren, removeAllChildrenWithCleanup, removeChild, removeChildByTag, removeFromParent, removeFromParentAndCleanup, reorderChild, resumeSchedulerAndActions, retain, runAction, schedule, scheduleOnce, scheduleUpdate, scheduleUpdateWithPriority, setActionManager, setAnchorPoint, setGLServerState, setGrid, setNodeDirty, setOrderOfArrival, setParent, setPosition, setPositionX, setPositionY, setRotation, setScale, setScaleX, setScaleY, setScheduler, setShaderProgram, setSkewX, setSkewY, setTag, setUserData, setUserObject, setVertexZ, setVisible, setZOrder, sortAllChildren, stopAction, stopActionByTag, stopAllActions, transform, transformAncestors, unschedule, unscheduleAllCallbacks, unscheduleUpdate, update, updateTransform, visit, worldToNodeTransform
Class Detail
cc.RenderTexture()
cc.RenderTexture is a generic rendering target. To render things into it,
simply construct a render target, call begin on it, call visit on any cocos
scenes or objects to render them, and call end. For convienience, render texture
adds a sprite as it's display child with the results, so you can simply add
the render texture to your scene and treat it like any other CocosNode.
There are also functions for saving the render texture to disk in PNG or JPG format.
Field Detail
{HTMLCanvasElement} canvas
the offscreen canvas for rendering and storing the texture

{CanvasContext} context
stores a reference to the canvas context object
Method Detail
begin()
starts grabbing

beginWithClear(r, g, b, depthValue, stencilValue, a)
starts rendering to the texture while clearing the texture first.
This is more efficient then calling -clear first and then -begin
Parameters:
{Number} r
red 0-255
{Number} g
green 0-255
{Number} b
blue 0-255
{Number} depthValue
{Number} stencilValue
{Number} a
alpha 0-255 0 is transparent

clear(r, g, b, a)
clears the texture with a color
Parameters:
{Number} r
red 0-255
{Number} g
green 0-255
{Number} b
blue 0-255
{Number} a
alpha 0-255

clearDepth(dep)
clears the texture with a specified depth value
Parameters:
{Number} dep

clearStencil(stencilValue)
clears the texture with a specified stencil value
Parameters:
{Number} stencilValue

<static> {cc.RenderTexture} cc.RenderTexture.create(width, height, format, depthStencilFormat)
creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
// Example
var rt = cc.RenderTexture.create()
Parameters:
{Number} width
{Number} height
{cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format
{Number} depthStencilFormat
Returns:
{cc.RenderTexture}

ctor()
Constructor

end()
ends grabbing

{HTMLCanvasElement} getCanvas()
Returns:
{HTMLCanvasElement}

{cc.Sprite} getSprite()
The sprite
Returns:
{cc.Sprite}

{Boolean} initWithWidthAndHeight(width, height, format, depthStencilFormat)
Parameters:
{Number} width
{Number} height
{cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format
{Number} depthStencilFormat
Returns:
{Boolean}

listenToBackground(obj)
Listen "come to background" message, and save render texture. It only has effect on Android.
Parameters:
{cc.Class} obj

{cc.Image} newCCImage()
creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete.
Returns:
{cc.Image}

saveToFile(filePath, format)
saves the texture into a file using JPEG format. The file will be saved in the Documents folder. Returns YES if the operation is successful.
Parameters:
{Number} filePath
{Number} format

setContentSize(size)
Parameters:
{cc.Size} size

setSprite(sprite)
Parameters:
{cc.Sprite} sprite

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:53 GMT-0800 (PST)