我正在尝试用Cocos 2D和Box 2D制作游戏
但是当我试图放一个"setAsEdge"时,它只是说我的功能不存在
我的代码:
// Define the ground body.
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0, 0); // bottom-left corner
// Call the body factory which allocates memory for the ground body
// from a pool and creates the ground box shape (also from a pool).
// The body is also added to the world.
groundBody = world->CreateBody(&groundBodyDef);
// Define the ground box shape.
b2PolygonShape groundBox;
// bottom
groundBox.SetAsEdge(b2Vec2(0,FLOOR_HEIGTH/PTM_RATIO), b2Vec2(screenSize.width*2.0f/PTM_RATIO,FLOOR_HEIGTH/PTM_RATIO));
groundBody->CreateFixture(&groundBox,0);
// top
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width*2.0f/PTM_RATIO,screenSize.height/PTM_RATIO));
groundBody->CreateFixture(&groundBox,0);
// left
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(0,0));
groundBody->CreateFixture(&groundBox,0);
// right …Run Code Online (Sandbox Code Playgroud) 我正在iOS上制作我的第一个游戏,我需要加载一些存储为XML的级别.级别文件存储在本地,一切都可以从模拟器中正常工作.但是,由于XML在运行时加载,当我尝试在实际设备上测试我的游戏时,它无法找到XML文件,因为它们实际上并不是应用程序的一部分.
我来自Flash背景,所以我可能错误地想知道如何在iOS上完成这项工作,但我需要以某种方式将这些XML文件与应用程序捆绑在一起,或者以某种方式将其嵌入到代码中?这可能吗?
非常感谢 :)
我统一使用了这些代码,并且收到了此错误。“运算符 > 不能用于左侧的‘对象’类型和右侧的‘对象’类型。对我来说,这就像游戏引擎的统一脚本中的一个错误,你怎么看??
var PlayerNames = ["john","doe","potato"];
var PlayerScores = [3,2,5];
if(PlayerScores[1] < PlayerScores[0])
print("potato");
Run Code Online (Sandbox Code Playgroud) 我一直打字NSStrung和NSStrong为NSString.它今天非常糟糕,它让我希望我有一个全球化的别名,所以他们的工作就像NSString.
这让我想知道这是否有可能在Xcode中为类名(或函数)设置全局别名?无需编写代码.
也许甚至有一些方法我可以Xcode自动更正NSStrung和NSStrong到NSString,或者在任何程序中执行此操作的工具.
我不明白如何创建一个连接来连接SpriteKit中的两个实体.感谢帮助.
我想检测哪个精灵被触摸。如果我做 :
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchMoved, this);
listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), mySprite);
Run Code Online (Sandbox Code Playgroud)
然后在我的触摸方法中我这样做:
bool HelloWorld::onTouchBegan(Touch* touch, Event* event)
auto spriteBlock = static_cast<Block*>(event->getCurrentTarget());
Run Code Online (Sandbox Code Playgroud)
精灵被很好地检测到。
问题是我在图层上有大约 20 个精灵,我需要能够检测到它们,我需要设置吗
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), mySprite);
Run Code Online (Sandbox Code Playgroud)
对于每个精灵?
我知道你可以通过在游戏开始时创建它们来预加载spritenodes,但有没有更有效的方法呢?
我在这里遇到了问题.我正在使用SKSpriteNode在世界中创建不同的对象.我已经应用了重力自我,即SkScene.
所以,这里的问题是当我创建一个SKSPriteNode并为其物理体提供质量时,它每次都表现相似.例如:
如果我把质量作为0然后它也会下降(它不应该因为质量为零,所以根据物理规则体不应该下降质量为0).
现在,如果我将质量改为10或100或甚至1000,它会以与0质量相同的速度下降.
有没有人有同样的问题?或者任何人都可以帮助我吗?
我在制作复杂(ish)相机行为(使用 Javascript)时遇到了问题。我遇到的问题是我无法在我的球员身后获得位置。请不要告诉我使用 Vector3.back 等,因为我想要本地位置,以支持转弯。如果相机总是设置在那个位置,它就不会工作,因为我有一个很酷的运动系统。
我尝试了多种方法,并把自己与数学混淆了。我也尝试过复杂的加法和减法。他们都没有工作。
我想我可能遗漏了一些非常简单的东西,比如进入局部坐标等的方法。(或者可能是一些数学函数)
提前致谢 -Etaash
我不知道为什么,但是当我用平移连续移动球体时,当球体和墙壁之间存在接触时,球体会在墙内进入一点点.
我附上了一个小视频,我的FSM和我球体的检查员.
非常感谢您的帮助 ...
问候,
安东尼
我的FSM:https: //www.dropbox.com/s/nvohgkdvq5rd9pd/Capture%20d%E2%80%99%C3%A9cran%202014-06-12%20%C3%A0%2012.51.04.png
检查员:https://www.dropbox.com/s/1ec3numdfx33lbp/Capture%20d%E2%80%99%C3%A9cran%202014-06-12%20%C3%A0%2012.52.15.png
视频:https: //www.dropbox.com/s/kq4nfu3t6j2mprz/tile%20collision.mp4
objective-c ×4
ios ×3
sprite-kit ×3
skspritenode ×2
unityscript ×2
xcode ×2
alias ×1
autocorrect ×1
c++ ×1
cocos2d-x ×1
coordinates ×1
fsm ×1
iphone ×1