MCPcopy Create free account
hub / github.com/axmolengine/axmol / init

Method init

tests/cpp-tests/Source/Physics3DTest/Physics3DTest.cpp:95–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95bool Physics3DTestDemo::init()
96{
97 if (!TestCase::init())
98 return false;
99
100 if (initWithPhysics())
101 {
102 getPhysics3DWorld()->setDebugDrawEnable(false);
103
104 physicsScene = this;
105 Size size = Director::getInstance()->getWinSize();
106 _camera = Camera::createPerspective(30.0f, size.width / size.height, 1.0f, 1000.0f);
107 _camera->setPosition3D(Vec3(0.0f, 50.0f, 100.0f));
108 _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f));
109 _camera->setCameraFlag(CameraFlag::USER1);
110 this->addChild(_camera);
111
112 auto listener = EventListenerTouchAllAtOnce::create();
113 listener->onTouchesBegan = AX_CALLBACK_2(Physics3DTestDemo::onTouchesBegan, this);
114 listener->onTouchesMoved = AX_CALLBACK_2(Physics3DTestDemo::onTouchesMoved, this);
115 listener->onTouchesEnded = AX_CALLBACK_2(Physics3DTestDemo::onTouchesEnded, this);
116 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
117
118 TTFConfig ttfConfig("fonts/arial.ttf", 10);
119 auto label = Label::createWithTTF(ttfConfig, "DebugDraw OFF");
120 auto menuItem = MenuItemLabel::create(label, [this, label](Object* /*sender*/) {
121 if (getPhysics3DWorld()->isDebugDrawEnabled())
122 {
123 getPhysics3DWorld()->setDebugDrawEnable(false);
124 label->setString("DebugDraw OFF");
125 }
126 else
127 {
128 getPhysics3DWorld()->setDebugDrawEnable(true);
129 label->setString("DebugDraw ON");
130 }
131 });
132
133 auto menu = Menu::create(menuItem, nullptr);
134 menu->setPosition(Vec2::ZERO);
135 menuItem->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
136 menuItem->setPosition(Vec2(VisibleRect::left().x, VisibleRect::top().y - 50));
137 this->addChild(menu);
138
139 _angle = 0.0f;
140 return true;
141 }
142 physicsScene = nullptr;
143 return false;
144}
145
146void Physics3DTestDemo::onTouchesBegan(const std::vector<Touch*>& touches, ax::Event* event)
147{

Callers

nothing calls this directly

Calls 15

getPhysics3DWorldFunction · 0.85
getInstanceFunction · 0.85
createFunction · 0.85
leftFunction · 0.85
topFunction · 0.85
createFromAxisAngleFunction · 0.85
lookAtMethod · 0.80
setScaleZMethod · 0.80
addComponentMethod · 0.80
setTransparentMethod · 0.80

Tested by

no test coverage detected