-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLAppPal.cpp
53 lines (46 loc) · 1.26 KB
/
LAppPal.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
#include "LAppPal.hpp"
#include <Model/CubismMoc.hpp>
#include "cocos2d.h"
using namespace Csm;
using namespace cocos2d;
csmByte* LAppPal::LoadFileAsBytes(const csmChar* filePath, csmSizeInt* outSize)
{
ssize_t size = 0;
csmByte* buf = FileUtils::getInstance()->getDataFromFile(filePath).takeBuffer(&size);
*outSize = static_cast<csmSizeInt>(size);
return buf;
}
void LAppPal::ReleaseBytes(csmByte* byteData)
{
free(byteData);
}
csmFloat32 LAppPal::GetDeltaTime()
{
if(Director::getInstance())
{
return Director::getInstance()->getDeltaTime();
}
return 0.0f;
}
void LAppPal::PrintLog(const csmChar* format, ...)
{
va_list args;
csmChar buf[256];
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args); // 標準出力でレンダリング
cocos2d::log("%s", buf); // cocos2dのログ関数で出力
va_end(args);
}
void LAppPal::PrintMessage(const csmChar* message)
{
std::string s = message;
if (s.back() == '\n')
s.pop_back();
PrintLog("%s", s.c_str());
}