Example
// Get url parameter
console.log(SINT.Unit.getUrlStr('id'));
// Convert deg to Rad
console.log(SINT.Unit.degToRad(30));
// Load json
SINT.Unit.loadJson('*.json').then(function(json) {
console.log(json);
}, function(error) {
console.error('loadJson Erro', error);
}
// Post json
let sendData = {'idStr': '***'};
SINT.Unit.postJson('..*.php', sendData).then(function(data) {
console.log(JSON.parse(data.jsonStr));
}, function(error) {
console.error('postJson Erro', error);
}
Methods
-
Name Type Description canvasHTMLCanvasElement optional the source object of the texture.
Returns:
Type Description HTMLImageElement - img Element.
-
Name Type Description degreesnumber optional Returns:
Type Description number The number of Rad -
Name Type Description imgHTMLImageElement optional the source object of the texture.
wnumber optional width
hnumber optional height
Returns:
Type Description Array.<number> - An array representing the [R, G, B ,A] of the color.
-
Name Type Description imgHTMLImageElement optional the source object of the texture.
wnumber optional width
hnumber optional height
Returns:
Type Description Array.<number> - An array representing the [R, G, B] of the color.
-
获取两点方向角度
Name Type Description pointStartSINT.Point pointToSINT.Point Returns:
Type Description number Example
var p1 = new SINT.Point(10, 10); var p2 = new SINT.Point(50, 30); SINT.Unit.getPointAngle(p1, p2); //=> Angle -
获取两点距离
Name Type Description pointStartSINT.Point pointToSINT.Point Returns:
Type Description number Example
var p1 = new SINT.Point(10, 10); var p2 = new SINT.Point(50, 30); SINT.Unit.getPointDistance(p1, p2); //=> Distance -
Name Type Description txtstring optional the string of text.
sizenumber optional the font size of text.
Returns:
Type Description HTMLImageElement - img Element.
-
Name Type Description namestring optional Returns:
Type Description string The string url parameter -
检测两个显示对象是否相交,一般用于检测碰撞
注意:边缘重叠始终返回true
Name Type Description rectASINT.Rectangle rectBSINT.Rectangle Returns:
Type Description boolean Example
var rect1 = new SINT.Rectangle(10, 10, 50, 50); var rect2 = new SINT.Rectangle(50, 30, 50, 50); SINT.Unit.isIntersectsRect(rect1, rect2); //=> true -
Name Type Description urlstring optional the json url.
Returns:
Type Description Promise - Promise
-
Name Type Description urlstring optional the json url.
sendDataobject optional the object of data.
Returns:
Type Description Promise - Promise
-
检测一个显示对象是否在另一个矩形内部
注意:边缘重叠始终返回fasle
Name Type Description rectSINT.Rectangle objSINT.Rectangle | SINT.Point Returns:
Type Description boolean Example
var rect1 = new SINT.Rectangle(10, 10, 100, 100); var rect2 = new SINT.Rectangle(30, 30, 50, 50); SINT.Unit.isContainsRect(rect1, rect2); //=> true