Comments (10)
I got an idea :
You make a Tile class and each Tile will have a std::map<std::string /Property/, std::string /Value/> mProperties
With that the user can set property for animated tile or any property he wants
The Tile are stored on a Layer (I think you can also make a class Layer) maybe on a std::vector <std::vector >
A Tile can modify the texture of itself directly by modify the VertexArray of the Layer
Then the user can do that :
For (layer.getTile ())
{
if (Tile.hasProperty ("animated") && Tile.hasProperty ("water")
{
Myvectoroftileofwater.pushback (Tile);
}
}
And then he can modify the texture each x second like that :
Void update(time)
{
tileTime = Tile.getValueOf ("animated-time").asTime ();
If (tileTime >= time)
{
Tile.switchTextureRect ();
}
}
My code is an example in pseudo code but I think you understand what I mean :)
(I'm on my phone and I'm French so the corrector automatic isnt cool at all for speaking English and write code...)
from sfml-tmxloader.
Little bug for the container of Tile in Layer :
Std::vector < std::vector < Tile > >
from sfml-tmxloader.
OK I think I get what you mean. There are already Tile and Layer structs so modifying them wouldn't be a stretch. What I really need to think about is how Tiled itself should mark a tile as being animated. When you design a map it has no direct support for animated tile maps. Perhaps it would be as simple as adding a pointer to an sf::Drawable to the tile struct and providing public access so users can attach any drawable they like (including animated sprite) which the map loader will draw when the pointer != nullPtr
from sfml-tmxloader.
In the Tiled editor you can add properties to Tiles
I think that's the best way to handle animated Tiles. This method allow also so much possibilities so I think that a great feature to had.
I will see in the anothers tiled loader how they handle animated tiles
from sfml-tmxloader.
Okay I've just seen the TinyXML Loader : http://code.google.com/p/tmx-parser/
It use a system like I told you with property :)
from sfml-tmxloader.
Right, in which case there's probably not much to do. Object properties are already parsed and publicly available, so if a user wants to look for an animated property in an object and handle it in whichever way they see fit, they can.
from sfml-tmxloader.
Actually animated tiles were first implemented in Tiled around the time this issue was posted. These are stored in xml like this:
<tile id="31">
<animation>
<frame tileid="31" duration="100"/>
<frame tileid="34" duration="100"/>
</animation>
</tile>
from sfml-tmxloader.
always happy to accept pull requests on the Next branch! ;)
from sfml-tmxloader.
Any news on this?
I've been able to grab the animation data like @Kojirion showed and load it into TileInfo but that's as far as I've gotten while I pick apart your code.
The first problem I'm going to have is that I don't know how to easily convert the local tile ID given in the tag to the global ID that would presumably be needed for rendering the appropriate frame.
The second problem I'm going to have is that I'm not quite sure how the rendering itself works in your code at this time. It looks like you are rendering layer sets which use MapTile but it seems that MapTile is only used in Image layers which I'm not using.
from sfml-tmxloader.
I know it's probably not what you want to hear, but I've pretty much abandoned this in favour of tmxlite - although I see you've already forked it ;) You'll be able to get all of your animation data out of it, but will have to set up the rendering yourself.
from sfml-tmxloader.
Related Issues (20)
- Thanks Matt! HOT 3
- No compatibility with AnimatedSprite class? HOT 2
- MapObject setVisible ? HOT 3
- Terrain Tiled tmx load HOT 3
- Strange culling HOT 4
- Collision issues HOT 7
- Animated Tile with Tiled Editor HOT 4
- layer->tiles doesn't give tiles from layers HOT 3
- GetLayers() doesn't work as spected HOT 4
- Simple test fails: call for help
- Unresolved external symbol HOT 12
- Can't draw map properly if it wasn't the the first one the maploader loaded. HOT 4
- Colission with player sprite HOT 6
- Collisions detected incorrectly due to AABB having incorrect height (2x what it should be) HOT 1
- Isometric causing weird issues HOT 5
- unresolved symbol sf::Sprite::Draw in MapLoaderPublic.obj? HOT 1
- Isometric Layering offset not happening? HOT 22
- Missing vtable HOT 3
- Can not build tmxsfml project as I've set link options correctly HOT 1
- Doesn't build woth MinGW Makefiles HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sfml-tmxloader.