Formatting

This commit is contained in:
Mario Zechner 2024-04-10 15:15:58 +02:00
parent e7b47f64f3
commit 34387d48d4
4 changed files with 12 additions and 12 deletions

View File

@ -53,21 +53,21 @@ bool PhysicsExample::init() {
// Next we setup a listener that receives and stores // Next we setup a listener that receives and stores
// the current mouse location and updates the skeleton position // the current mouse location and updates the skeleton position
// accordingly. // accordingly.
EventListenerMouse *mouseListener = EventListenerMouse::create(); EventListenerMouse *mouseListener = EventListenerMouse::create();
mouseListener->onMouseMove = [this](cocos2d::Event *event) -> void { mouseListener->onMouseMove = [this](cocos2d::Event *event) -> void {
// convert the mosue location to the skeleton's coordinate space // convert the mosue location to the skeleton's coordinate space
// and store it. // and store it.
EventMouse *mouseEvent = dynamic_cast<EventMouse *>(event); EventMouse *mouseEvent = dynamic_cast<EventMouse *>(event);
Vec2 mousePosition = skeletonNode->convertToNodeSpace(mouseEvent->getLocationInView()); Vec2 mousePosition = skeletonNode->convertToNodeSpace(mouseEvent->getLocationInView());
if (firstUpdate) { if (firstUpdate) {
firstUpdate = false; firstUpdate = false;
lastMousePosition = mousePosition; lastMousePosition = mousePosition;
return; return;
} }
Vec2 delta = mousePosition - lastMousePosition; Vec2 delta = mousePosition - lastMousePosition;
skeletonNode->getSkeleton()->physicsTranslate(-delta.x, -delta.y); skeletonNode->getSkeleton()->physicsTranslate(-delta.x, -delta.y);
lastMousePosition = mousePosition; lastMousePosition = mousePosition;
}; };
_eventDispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this);

View File

@ -45,7 +45,7 @@ public:
private: private:
spine::SkeletonAnimation *skeletonNode; spine::SkeletonAnimation *skeletonNode;
bool firstUpdate = true; bool firstUpdate = true;
cocos2d::Vec2 lastMousePosition; cocos2d::Vec2 lastMousePosition;
}; };

View File

@ -192,7 +192,7 @@ struct AtlasInput {
line.end = index; line.end = index;
if (index != end) index++; if (index != end) index++;
line = line.trim(); line = line.trim();
line.length = (int)(end - start); line.length = (int) (end - start);
return &line; return &line;
} }

View File

@ -1164,7 +1164,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
timelines.add(readTimeline(timelineMap->_child, timeline, 0, 1)); timelines.add(readTimeline(timelineMap->_child, timeline, 0, 1));
} else if (strcmp(timelineMap->_name, "inherit") == 0) { } else if (strcmp(timelineMap->_name, "inherit") == 0) {
InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frames, boneIndex); InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frames, boneIndex);
keyMap = timelineMap->_child; keyMap = timelineMap->_child;
for (frame = 0;; frame++) { for (frame = 0;; frame++) {
float time = Json::getFloat(keyMap, "time", 0); float time = Json::getFloat(keyMap, "time", 0);
const char *value = Json::getString(keyMap, "value", "normal"); const char *value = Json::getString(keyMap, "value", "normal");