如何使用 c++ 在 cocos2d-x ios 游戏中使用 json 进行缩放
How to do scaling while using json in cocos2d-x ios game using c++
我正在使用cocostudio并从中导出一个场景,其中它导出了一个.plist,.png和一个.json文件。该场景在iPhone Retina 3.5英寸中工作正常,但在iPad和iPhone中缩放并不完美。如何在使用 .json 和导入不同设备的完整场景时控制缩放在我正在编写的初始化函数中
CCNode *pFishJoyScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("FishJoy2.json");
this->addChild(pFishJoyScene);
cocos2d::extension::ActionManager::shareManager()->playActionByName("startMenu_1.json","Animation1");
早些时候我曾经使用CCSize winsize=CCDirector::sharedDirector()->getwinSize();。在使用它时,我曾经缩放所有的东西。
但是对于 json,我们不需要写这个,因为我们正在 cocostudio 中创建场景。请告诉我如何在使用 .json 时控制不同设备中的缩放
我从中获取了示例示例https://github.com/chukong/CocoStudioSamples
我运行了上面示例中名为 DemoFishing joy 的项目。如果您在不同的设备中运行此示例项目,则会导致缩放问题。请帮忙
I hope this will help you.for scaling in skeletonAnimation setScaleX() and setScaleY() are used
CCSkeletonAnimation* skeletonAnimRun = CCSkeletonAnimation::createWithFile("horse.json", "horse.atlas");
skeletonAnimRun->setAnimation("run", true);
skeletonAnimRun->timeScale = 1.0f;
skeletonAnimRun->setScaleX(.2f);
skeletonAnimRun->setScaleY(.2f);
skeletonAnimRun->setPosition(x/5, y/2);
skeletonAnimRun->setSkin("black");
skeletonAnimRun->setSlotsToSetupPose();
addChild(skeletonAnimRun,10);
答案是,无论我拍摄什么场景还是任何东西,我都会在节点中获取。只需扩展节点,一切都会变得完美。例如
CCNode *pFishJoyScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("FishJoy2.json");
this->addChild(pFishJoyScene);
cocos2d::extension::ActionManager::shareManager()->playActionByName("startMenu_1.json","Animation1");
CCSprite *bg=CCSprite::create("startMenuBG.png");
float rX=winSize.width/bg->getContentSize().width;
float rY = winSize.height/bg->getContentSize().height;
pFishJoyScene->setScaleX(rX);
pFishJoyScene->setScaleY(rY);
然后,您将在任何设备中看到它工作完美
相关文章:
- UE4-如何在给定4个屏幕坐标的情况下缩放纹理或材质
- 计算缩放多边形的比例,得到给定的多边形面积
- QwtPlot具有相等的轴和自动缩放
- 如何在directx/c++中进行平移/缩放操作
- 在Qt中实现无限可缩放的画布
- 是否可以为 QPixmap 派生类嵌入缩放方法?
- 形状对象的旋转和缩放不正确C++
- 如何在 OpenSceneGraph 中缩放/旋转/移动资产
- 如何在OpenGL(GLFW,很高兴)中进行2D缩放?
- 改变或缩放两个正态分布以具有特定的相关系数
- SDL2 调整窗口大小后如何缩放鼠标坐标?
- 如何在OpenGL中正确旋转和缩放对象?
- 仅当类型为 std::complex 时,才进行缩放
- 将 VS Code 用于跨平台可缩放C++项目
- 根据帧速率缩放/缩小数字
- 在 c++ 中缩放浮点值
- 如何防止 DirectX C++程序的拉伸/缩放
- 使用提升几何缓冲区缩放多边形时的冗余折点
- 为什么我不能使用 Sphere 来缩放字形?
- 如何使用 c++ 在 cocos2d-x ios 游戏中使用 json 进行缩放