| 107 | } |
| 108 | |
| 109 | bool SpineTestLayer::init() |
| 110 | { |
| 111 | if (!TestCase::init()) |
| 112 | return false; |
| 113 | |
| 114 | EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create(); |
| 115 | listener->onTouchBegan = [this](Touch* touch, ax::Event* event) -> bool { |
| 116 | if (!skeletonNode) |
| 117 | return true; |
| 118 | _touchIndex = (_touchIndex + 1) % 3; |
| 119 | if (_touchIndex == 0) |
| 120 | { |
| 121 | skeletonNode->setDebugBonesEnabled(false); |
| 122 | skeletonNode->setTimeScale(1.0f); |
| 123 | } |
| 124 | else if (_touchIndex == 1) |
| 125 | { |
| 126 | skeletonNode->setDebugBonesEnabled(true); |
| 127 | skeletonNode->setTimeScale(1.0f); |
| 128 | } |
| 129 | else if (_touchIndex == 2) |
| 130 | { |
| 131 | skeletonNode->setDebugBonesEnabled(true); |
| 132 | skeletonNode->setTimeScale(0.3f); |
| 133 | |
| 134 | // refer issue: https://github.com/axmolengine/axmol/issues/482 |
| 135 | // Get Spine node PS and update uniforms |
| 136 | auto skeleton1PS = skeletonNode->getProgramState(); |
| 137 | |
| 138 | if (skeleton1PS) |
| 139 | { |
| 140 | Vec2 resolution{100.f, 100.f}; |
| 141 | float blurRadius = 50.0f; |
| 142 | float sampleNum = 7.0f; |
| 143 | |
| 144 | // This doesn't work on Spine node, works on sprite node |
| 145 | SET_UNIFORM(skeleton1PS, "resolution", resolution); |
| 146 | SET_UNIFORM(skeleton1PS, "blurRadius", blurRadius); |
| 147 | SET_UNIFORM(skeleton1PS, "sampleNum", sampleNum); |
| 148 | } |
| 149 | |
| 150 | } |
| 151 | return true; |
| 152 | }; |
| 153 | _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); |
| 154 | |
| 155 | SCALE_SKELETON_NODE(skeletonNode); |
| 156 | |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | // BatchingExample |
| 161 | bool BatchingExample::init() |
nothing calls this directly
no test coverage detected