Page 60 of 92
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Thu Sep 22, 2016 10:35 pm
by Karai17
The case of the haunted TMX file!
And yes, if you set an object's properties (collidable:true, sensor:true), then it will create a "hollow" collision (you won't bounce off of the box). This allows you to execute a callback.
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Thu Sep 22, 2016 10:55 pm
by Jimlarck
Karai17 wrote:The case of the haunted TMX file!
And yes, if you set an object's properties (collidable:true, sensor:true), then it will create a "hollow" collision (you won't bounce off of the box). This allows you to execute a callback.
Does STI check for sensor:true? Do you have any code examples?
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Thu Sep 22, 2016 11:01 pm
by Karai17
Yes it does (it's in the docs). I don't have any examples unfortunately. I'm not terribly familiar with box2d. Maybe you could come and hang out in the #love IRC channel and see if someone there knows more?
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Thu Sep 22, 2016 11:05 pm
by Jimlarck
Karai17 wrote:Yes it does (it's in the docs). I don't have any examples unfortunately. I'm not terribly familiar with box2d. Maybe you could come and hang out in the #love IRC channel and see if someone there knows more?
Alright cool I'll check it out!
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Sat Sep 24, 2016 6:22 pm
by AlexCalv
I'm having a tough time understanding how to implement STI into my game. I'm making a tower defense game and what I have setup are rectangle objects in areas that towers CAN be placed on, and I have a polygon shape object created to specify the path that I wanted enemies to take.
I have no idea how I can call to the objects and check to see if I can place one of my towers onto the object or not. And I would also like to know if I can use the object shapes and make something follow the line. I really have no idea if I'm using Tiled correctly either lol.
Here's my project file:
Link
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Sun Sep 25, 2016 1:34 am
by Karai17
Each object has a properties table you can access, so you can give an object properties such as flags to let your program know what can be built there.
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Mon Sep 26, 2016 7:14 am
by AlexCalv
Karai17 wrote:Each object has a properties table you can access, so you can give an object properties such as flags to let your program know what can be built there.
Right, I understand I need to do that. But I don't understand your documentation because of lack of examples.
Code: Select all
function tower.PlaceAtMouse(x, y)
for i,v in pairs(map.objects) do
getPlayableAreaProperties()
if v.canPlace== true then
tower.Spawn(mouseX - 16, mouseY - 16, tower.selected)
printDevMsg("SPAWNED " .. string.upper(tower.selected) .. " AT: " .. mouseX - 16 .. ", " .. mouseY - 16)
end
end
end
function getPlayableAreaProperties()
for i,v in pairs(map.objects) do
if v.name == "playable_area" then
map:getObjectProperties("towerAreas", "playable_area")
end
end
end
I honestly don't understand how to incorporate STI into my game.
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Mon Sep 26, 2016 7:20 pm
by Karai17
So you want to mouse over an STI object to determine what kind of units can be placed there?
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Tue Sep 27, 2016 6:46 am
by AlexCalv
Karai17 wrote:So you want to mouse over an STI object to determine what kind of units can be placed there?
Correct. I also wanted to know if I can use a polygon shape as like a "rail" for my enemies to follow. Or if I have to use a pathfinding algorithm.
Re: Simple Tiled Implementation - STI v0.16.0.3
Posted: Tue Sep 27, 2016 6:55 am
by Karai17
I would recommend using an axis-aligned bounding box (a rectangle with 0 rotation) and do an
AABB check on the object to see if your mouse pointer is "colliding" with the box.
As for rails, I would recommend checking out
Jumper, an
A* path finding library. I'm sure you could use a rail, but I've never tried.