Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Array to Object #23

Closed
T00mm opened this issue Oct 18, 2018 · 4 comments · Fixed by #162
Closed

Feature Array to Object #23

T00mm opened this issue Oct 18, 2018 · 4 comments · Fixed by #162

Comments

@T00mm
Copy link

T00mm commented Oct 18, 2018

layers: ITiledMapLayer[];

At the moment it is hard to easily get the layer you want, you mist iterate and check names. It would be much easier if we could use and object so we can access layers through their name

Current code needs:

  var gameObjectsLayer;
  for(var layer of map.data.layers){
    if(layer.name === "GameObjects"){
      gameObjectsLayer = layer;
      break;
    }
  }

Would be much nicer to use map.data.layers["GameObjects"]

What do you guys think?

@T00mm
Copy link
Author

T00mm commented Oct 18, 2018

Same for "objects" in a layer. With Tiled we can name objects but to access them we must write clunky code atm.

@eonarheim
Copy link
Member

@T00mm Agreed, the way it is now cumbersome. I generally like being able to get at things by name.

@kamranayub any objections?

@kevin192291
Copy link

Hey Guys! I was reading through this, and I had pulled a version of the tiled loader a long time ago and made this update on my local branch.
The main reason I made the change was for more efficient searches for when I was adding the ability to get tile properties.
I am wondering if this issue is still needing help. I would love to get what I have done merged into the repo if not. I am relying heavily on the tile properties right now.
Or am I just way out of date and this feature has already been added and I am just being annoying?

@eonarheim
Copy link
Member

@kevin192291 For sure this does need some more help, I think we left off wanting a few things:

  • An alternate more convenient api
  • Strong typing
  • Avoiding a breaking change

eonarheim added a commit to excaliburjs/Excalibur that referenced this issue Jan 30, 2021
Related issues:
* TileMap PR: excaliburjs/excalibur-tiled#162
* TMX support: excaliburjs/excalibur-tiled#4
* Full TSX external TileMap support: excaliburjs/excalibur-tiled#23,
* Object model to easily work with layers: excaliburjs/excalibur-tiled#108

## Changes:
* Remove `TileSprite` in favor of `Sprite`
* Fix some bugs with scaling/rotation of Sprites
   - Add `fromAnchor` to draw around anchor or from the left corner
   - Anchor still defines where rotations/scaling is applied to the sprite
eonarheim added a commit that referenced this issue Aug 27, 2021
## Summary

This PR introduces full support for parsing all of Tiled's supported data formats. Additional there is object model and build in Excalibur Tile Map support for everything except orthographic or hexagonal maps.

This is a breaking change,
* We are going to change how official plugins are packaged `@excaliburjs/plugin-tiled` the old package will remain unchanged
* We are going to re-align our versions to map to Excalibur in prefix
    * Excalibur@v0.25.x = @excaliburjs/plugin-tiled@v0.25.y 

## Features

* Parse default Tiled tmx files
  - Supports all Tiled compressions zlib, gzip, and zstd
* Parse Tiled exported json files
* Supports external tilesets `.tsx` and `json`
* New TypeScript based object model for working with Tiled data
  * Query for layers by property
  * Query for objects by property
  * Easy helpers to locate Polygons, Polylines, and Text
* Automatic Excalibur wiring for certain Tiled properties and objects:
  * Camera
  * Colliders
  * Solid TileMap Layers
  * Tiled Text
  * Inserted Tiled Tiles

### Excalibur Wiring

You may opt-in to the Excalibur wiring by calling `addTiledMapToScene(someScene)`

```typescript
// After loading tiledMapResource
tiledMapResouce.addTiledMapToScene(game.currentScene);
```

* Camera Position & Zoom - You may set the starting camera position and 
  - In an object layer with a custom property "excalibur"=true
  - Create a Tiled "Point" with the Tiled Type "Camera"
  - Optionally, to set zoom other than the default of 1.0, create a custom property named "Zoom" with a numeric value

* Solid layers - You can mark a particular layers tiles as solid in Tiled
  - In the Tiled layer properties, add a custom property named "Solid" with a boolean value `true`
  - The presence of a tile in this layer indicates that space is solid, the abscence of a tile means it is not solid

* Colliders - You may position Excalibur colliders within Tiled
  - In an object layer with a custom property "excalibur"=true
  - Create a "Circle" (ellipses are not supported) or "Rectangle"
     - Set the Tiled type to "BoxCollider" or "CircleCollider" 
     - Optionally, to set an Excalibur collision type specify a custom property named "CollisionType" with the value
        - "Fixed" (default for colliders) - non-movable object
        - "Passive" - triggers events, does not participate in collision
        - "Active" - participates in collision and can be pushed around
        - "PreventCollision" - all collisions are ignored

* Text - You may insert excalibur labels within Tiled
   - In an object layer with a custom property "excalibur"=true
   - Create a Tiled Text object

* Inserted Tiles - You may insert tiles off grid in Tiled
   - In an object layer with a custom property "excalibur"=true
   - Create a Tiled inserted Tile
   - Optionally, to set an Excalibur collision type specify a custom property named "CollisionType" with the value
        - "Fixed" non-movable object
        - "Passive" (default for inserted tiles) - triggers events, does not participate in collision
        - "Active" - participates in collision and can be pushed around
        - "PreventCollision" - all collisions are ignored

TODO before merge:
* [x] Update to alpha Excalibur build for CI
* [x] GH Actions
* [x] Integration Test
* [x] Delete notes
* [x] Update examples
* [x] Compatibility with new Excalibur Graphics API

Closes:
* TMX support: Closes #4
* Full TSX external TileMap support: Closes #23,
* Object model to easily work with layers: Closes #108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants