more detail on library integration

pull/1/head
Evan Hemsley 2019-05-29 12:59:23 -07:00
parent d0b7d6d35d
commit 69a207af67
1 changed files with 3 additions and 3 deletions

View File

@ -10,9 +10,9 @@ Now we need to declare that library to TypeScript so we can use it in our game c
If you'd like a very detailed description of declaration files and how they work, I recommend perusing the [official documentation](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html). But I will give a specific use-case walkthrough here.
First, we need to find out which functions of the library we are actually going to use. If we look over the bump.lua documentation, we see that the library asks us to initialize a "world" using *bump.newWorld*, add rectangles to the world with *world:add*, and declare their movements using *world:move*.
First, we need to find out which functions of the library we are actually going to use. If we look over the bump.lua documentation, we see that the library asks us to initialize a "world" using *bump.newWorld*, add rectangles to the world with *world:add*, and declare their movements using *world:move*. We can also use *world:check* and *world:update* for finer control over the rectangles.
First, let's download _bump.lua_ and place it in the lua-lib folder.
First, let's download _bump.lua_ and place it in the lua-lib folder. This ensures that the library will be included in your game during the build process.
In the lua-lib folder, let's create a new file: **lua-lib/bump.d.ts**
@ -48,7 +48,7 @@ export interface World {
}
```
In Lua, *table* is our generic object. All of our classes and other objects are translated to tables when using TSTL.
In Lua, *table* is our generic object. All of our classes and other objects are translated to tables when using TSTL, so it's a convenient type for generic objects.
"add" is a pretty straightforward function: it takes a position and a width and height and adds that rectangle to the World.