Hitbox
跳到导航
跳到搜索
Hitbox (aka collision box) is geometry used for collision detection. In LuaSTG, a hitbox is always attached to a game object.
- There are three parameters for a hitbox: a, b and shape. They correspond to a, b and rect property of game object.
碰撞盒(又称碰撞体)是用于碰撞检测的几何体。在LuaSTG中,碰撞盒总是附于游戏对象上。
- 碰撞盒具有三个参数:a,b 和形状,分别对应游戏对象的 a,b 和 rect 属性。
Hitbox (aka collision box) is geometry used for collision detection. In LuaSTG, a hitbox is always attached to a game object.
- There are three parameters for a hitbox: a, b and shape. They correspond to a, b and rect property of game object.
Engines other than LuaSTG-xLuaSTG-x以外的引擎Engines other than LuaSTG-x
In engines other than LuaSTG-x, hitbox can be following shapes:
在LuaSTG-x以外的引擎中,碰撞盒可以为以下形状:
In engines other than LuaSTG-x, hitbox can be following shapes:
Green arrow indicates orientation of game object, which is rot property.
- When rect property is (set to) false, shape of hitbox will be circle.
- When rect property is (set to) true, shape of hitbox will be rectangle.
其中绿色箭头表示游戏对象的朝向,即 rot 属性。
- 当 rect 属性为 false 时,对应圆形碰撞盒。
- 当 rect 属性为 true 时,对应矩形碰撞盒。
Green arrow indicates orientation of game object, which is rot property.
- When rect property is (set to) false, shape of hitbox will be circle.
- When rect property is (set to) true, shape of hitbox will be rectangle.
LuaSTG-x
In LuaSTG-x, hitbox can be following shapes:
在LuaSTG-x中,碰撞盒可以为以下形状:
In LuaSTG-x, hitbox can be following shapes:
- a property and b property can not be negative number, or the engine will throw an error.
- When rect property is assigned with a boolean value, the behavior is same as other engines.
- When rect property is assigned with a number value or a string value, the shape will be set according to following table:
- a 属性和 b 属性不能为负数,否则引擎会抛出错误。
- 当 rect 属性被设置为布尔值时,行为与其他引擎相同。
- 当 rect 属性被设置为数字或字符串值时,将按照下表设置碰撞盒形状。
- a property and b property can not be negative number, or the engine will throw an error.
- When rect property is assigned with a boolean value, the behavior is same as other engines.
- When rect property is assigned with a number value or a string value, the shape will be set according to following table:
ID | String 字符串 String
|
Shape 形状 Shape
|
---|---|---|
0 | "circle" | Circle 圆形 Circle
|
1 | "obb" | Rectangle 矩形 Rectangle
|
2 | "ellipse" | Ellipse 椭圆 Ellipse
|
3 | "diamond" | Diamond 菱形 Diamond
|
4 | "triangle" | Triangle 三角形 Triangle
|
5 | "point" | Point 点 Point
|
- When shape of hitbox is cirlce, rect property will return false. This is for compatibility.
- When shape of hitbox is not cirlce, rect property will return ID of the shape.
- 出于兼容性考虑,当碰撞盒形状为圆形时,读取 rect 属性时返回 false。
- 当碰撞盒形状不为圆形时,读取 rect 属性时返回对应ID。
- When shape of hitbox is cirlce, rect property will return false. This is for compatibility.
- When shape of hitbox is not cirlce, rect property will return ID of the shape.