c++ - 在 Visual Studio 的 cocos2d 中添加 Sprite 时出现未处理的异常

标签 c++ windows-phone-8 visual-studio-2013 cocos2d-x

<分区>

Unhandled exception at 0x0096348B in HelloWorld.exe: 0xC0000005: Access violation reading location 0x00000000.

这是我在尝试使用我添加的 Sprite 时遇到的错误。

CCSprite *sprite = CCSprite::spriteWithFile("Untitled.png" );
sprite->setAnchorPoint(CCPointZero);
this->addChild(sprite, -1);

错误在第一行

感谢您的帮助。

我正在使用 Visual Studio 2013

最佳答案

        Try! this it works for me.
  CCSize screenSize   = CCDirector::sharedDirector()->getVisibleSize();
        pointOrigin  = CCDirector::sharedDirector()->getVisibleOrigin();
        x = screenSize.width;
        y = screenSize.height;


    CCSprite* sprite=CCSprite::create("icon.png");
        sprite->setPosition(ccp(x/2,y/2));
        addChild(sprite,1);

关于c++ - 在 Visual Studio 的 cocos2d 中添加 Sprite 时出现未处理的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21081274/

相关文章:

c++ - 结构的 "type"是否会因计算机而异?

java - 如何将 int 放入 HashMap jni 中?

c# - 如何将 Storyboard动画应用于多个 xaml 元素

c# - Marshal.GetActiveObject ("Outlook.Application") 在使用提升的权限进行调试时抛出 MK_E_UNAVAILABLE

c++ - 在调试器上的 CStringArray 中显示元素一再一?

c++ - 将字符串转换为整数产生了意想不到的结果

c++ - 运行时进程名称更改 (C++)

c# - 如何使视频在 Windows Phone 8 App XAML 和 C# 中恢复播放

c# - 通过引用而不是通过值传递的对象

iis - HTTP 错误 405.0 - IIS Express 中不允许的方法