객체 텍스쳐 복사
--
function g_CutPicture(pContainer)
local winSize = cc.Director:getInstance():getWinSize();
local aniSize = pContainer:getContentSize();
--aniSize = cc.size(120,200);
local aniAnchorPoint = cc.p( pContainer:getAnchorPoint() );
--print(aniAnchorPoint.x,aniAnchorPoint.y);
aniAnchorPoint.x = 0.5;
local worldPos = pContainer:getParent():convertToWorldSpace( cc.p( pContainer:getPosition() ) );
local cutSizeWidth = worldPos.x + aniSize.width*(1 - aniAnchorPoint.x);
local cutSizeHeight = worldPos.y + aniSize.height*(1 - aniAnchorPoint.y);
-- cutSizeWidth = cutSizeWidth > 0 and cutSizeWidth or -1;
-- cutSizeHeight = cutSizeHeight > 0 and cutSizeHeight or -1;
-- print(cutSizeWidth,cutSizeHeight);
local rt = nil;
if cutSizeWidth > 0 and cutSizeHeight > 0 then
rt = cc.RenderTexture:create( cutSizeWidth , cutSizeHeight );
else
print("-----------------------------------------");
print(pContainer:getPositionX(),pContainer:getPositionY());
print( "worldPos.x = "..worldPos.x.."; worldPos.y = "..worldPos.y );
print(cutSizeWidth,cutSizeHeight);
end
if rt then
rt:retain();
rt:beginWithClear(255,255,255,0);
--pContainer:visit();
--
function drawAllNode( node )
if node:getChildrenCount() > 0 and node:isVisible() == true then
for k,v in pairs( node:getChildren() ) do
drawAllNode(v);
-- v:visit();
end
end
if node:isVisible() == true then
node:visit();
end
end
drawAllNode(pContainer);
rt:endToLua();
local texture = rt:getSprite():getTexture();
local cutX = worldPos.x - aniSize.width*aniAnchorPoint.x;
local maxX = aniSize.width ;
-- if cutX < 0 then
-- --maxX = maxX + cutX;
-- --cutX = 0;
-- end
local cutY = worldPos.y - aniSize.height*aniAnchorPoint.y;
local maxY = aniSize.height ;
-- if maxY < 0 then
-- --maxY = maxY + cutY;
-- --cutY = 0;
-- end
local texRect = cc.rect( cutX,
cutY,
maxX,
maxY );
-- for k,v in pairs(texRect) do
-- print(k,v)
-- end
if texture then
local pSprite = cc.Sprite:createWithTexture(texture,texRect );
pSprite:setFlippedY(true);
pSprite:setAnchorPoint( aniAnchorPoint );
return pSprite;
end
rt:release();
rt = nil
end
return nil;
end
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.