You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
here the important source snippet (see on draw()):
#include "HelloWorldScene.h"
USING_NS_AX;
Scene* HelloWorld::createScene()
{
return HelloWorld::create();
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if (!Scene::init())
{
return false;
}
auto visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
mSpritesLayer = Layer::create();
mSpritesLayer->retain();
sprite = Sprite::create("mario_3x.png");
sprite->getTexture()->setAliasTexParameters();
sprite->setAnchorPoint(Vec2(0, 1));
sprite->setScale(visibleSize.height / mDesignSize.height);
sprite->setPositionY(visibleSize.height);
sprite->setPositionX(0);
mSpritesLayer->addChild(sprite);
// RenderTexture
mRTex = RenderTexture::create(visibleSize.width, visibleSize.height);
mRTex->setPosition(visibleSize.width / 2, visibleSize.height / 2);
this->addChild(mRTex, 100);
mNodeGrid = NodeGrid::create(Rect(origin,visibleSize));
mNodeGrid->retain();
mNodeGrid->setTarget(mSpritesLayer);
mFlipY3dAction = FlipY3D::create(1);
mFlipY3dAction->retain();
return true;
}
void HelloWorld::draw(ax::Renderer* renderer, const ax::Mat4& transform, uint32_t flags)
{
if (mTick == 50)
{
mNodeGrid->runAction(mFlipY3dAction);
mNodeGrid->resume();
}
mTick++;
Scene::draw(renderer, transform, flags);
// The code below works fine when RenderTexture is not used
// mRTex->beginWithClear(0, 0, 0, 0); // comment out and it works
mNodeGrid->visit(renderer, transform, flags); // maybe transform issue?
// mRTex->end(); // comment out and it works
}
wrong:
correct:
The text was updated successfully, but these errors were encountered:
aismann
changed the title
Also on axmol: Cococ2dx issue: https://github.com/cocos2d/cocos2d-x/issues/20767
Also on axmol: Cococ2dx issue: FlipY3D issue if setDesignResolution and RenderTexture is used
Feb 22, 2023
Steps to Reproduce:
see cocos2d/cocos2d-x#20767
=> has the full source also
here the important source snippet (see on draw()):
wrong:
correct:
The text was updated successfully, but these errors were encountered: