space debri
all alone » Devlog
cocos2dx 3D physics. Made a floor (tilt 20°) for 3D cubes that roll down towards the spaceship. The ship has to shoot or avoid those cubes. Could be some debri or satelites.
//create floor
Physics3DRigidBodyDes rbDes;
rbDes.mass = 0.0f;
rbDes.shape = Physics3DShape::createBox(Vec3(50.0f, 1.0f, 200.0f)); auto floor = PhysicsSprite3D::create("3d/box.c3t", &rbDes);
floor->setOpacity(0);
floor->setScaleX(50);
floor->setScaleY(1);
floor->setScaleZ(200);
floor->setRotation3D(Vec3(20, 0, 0));
floor->setPosition3D(Vec3(0, 0, 0));
this->addChild(floor);
floor->setCameraMask((unsigned short)CameraFlag::USER1);
floor->syncNodeToPhysics();
//static object sync is not needed
floor->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::NONE);
schedule(CC_SCHEDULE_SELECTOR(HelloWorld::placeDebri), 0.1f);
void HelloWorld::placeDebri(float dt){
Physics3DRigidBodyDes rbDes;
//create several boxes using PhysicsSprite3D
rbDes.mass = 0.1f;
rbDes.shape = Physics3DShape::createBox(Vec3(0.8f, 0.8f, 0.8f));
float x = -25 + rand_0_1()*50; float y = 34 ; float z = -90 ;
auto sprite = PhysicsSprite3D::create("3d/box.c3t", &rbDes);
sprite->setTexture("3d/ship.jpg");
sprite->setPosition3D(Vec3(x, y, z));
sprite->syncNodeToPhysics();
sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE);
sprite->setCameraMask((unsigned short)CameraFlag::USER1);
sprite->setScale(0.8f);
this->addChild(sprite);
}
all alone
https://itch.io/jam/red-iron-games-stay-at-home-jam
More posts
- changed to cocos creator for webgameApr 04, 2020
- collision, sound, menu and some bugsApr 02, 2020
Leave a comment
Log in with itch.io to leave a comment.