Commit graph

206 commits

Author SHA1 Message Date
photonstorm
7b011fe0d3 Fix #1742 2015-04-14 09:31:04 +01:00
photonstorm
f155ad452c Tilemap.createFromObjects has been updated for Tiled 0.11 and can now look-up object layers based on id, uid or name. It will also now copy over Sprite scaling properties if set (thanks @mandarinx #1738) 2015-04-13 12:40:12 +01:00
Richard Davey
78e7be5c96 Merge pull request #1738 from mandarinx/patch-1
Looking up object layers based on id, uid or name
2015-04-13 12:35:24 +01:00
photonstorm
7b8a430aac TilemapLayer docs incorrectly reported it as extending Phaser.Image, but it doesn't share the same components so has been updated.
TilemapLayer was missing the Input component (thanks @uhe1231 #1700)
2015-04-13 12:23:30 +01:00
Thomas Viktil
b406a61262 Looking up object layers based on id, uid or name
The description of the method stated that you could pass a string to look up an object layer based on its name, but the original code only looked for a gui property, regardless of type.

I'm using Tiled 0.11.0 on OSX, and my exported json-file doesn't contain a gui property on the object layers. Here's a snippet of my file:
```
{
    "layers":[
        {
         "draworder":"topdown",
         "height":0,
         "name":"Objects",
         "objects":[
                {
                 "height":48,
                 "id":1,
                 "name":"pier",
                 "properties":
                    {

                    },
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":64,
                 "x":208,
                 "y":240
                }],
         "opacity":1,
         "properties":
            {
             "type":"pier"
            },
         "type":"objectgroup",
         "visible":true,
         "width":0,
         "x":0,
         "y":0
        }]
    }]
}
```

The property in my file is called id and not uid. This might be due to changes in one of the later releases of Tiled. I kept the check for uid to avoid possibly breaking compatibility with older versions of Tiled.

I also added scaling of the sprite.

Feel free to make formatting changes, or rewrite the function to better fit the programming style of Phaser.
2015-04-11 22:16:17 +02:00
Alan Smithee
d2e3a69525 Adds nonNull parameter to Tilemap.getTileWorldXY
Since Tilemap.getTile lets you specify wether to return null
or an empty tile when index is -1, the WorldXY equivalent
should offer the same possibility for a more unified interface.
2015-04-06 10:08:37 +00:00
photonstorm
1486e166bd Added physicsType property. 2015-03-23 15:04:27 +00:00
Paul
dcc83ec793 Tilemap renderer - context save/restore
- Added context save/restore; the secondary issue when the canvas
  is copied from later, and if any alpha is applied
2015-03-16 22:05:46 -07:00
Paul
54dba67f50 Tilemap rendering sets initial state better
- #1666 - previous alpha state could bleed through.
  Now the initial alpha and composite modes are set explicitly.
2015-03-16 21:35:39 -07:00
photonstorm
f4eff6359c Added isArray check. 2015-03-05 14:02:24 +00:00
photonstorm
364f3b3cb8 Formatting. 2015-03-05 14:02:04 +00:00
Paul
0e5272b217 Merge remote-tracking branch 'upstream/dev' into wip-components-toproto
Conflicts:
	src/gameobjects/Image.js
	src/gameobjects/Rope.js
	src/gameobjects/Sprite.js
	src/gameobjects/Text.js
	src/gameobjects/TileSprite.js
	src/gameobjects/components/Core.js
2015-02-28 15:51:47 -08:00
Michael Zekoff
510353f6fb Fix row/col count formula.
This fixes the rendering issue for tilesets with margin/spacing
as described in photonstorm/phaser#1641.
2015-02-26 04:34:41 +00:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
c9939f8691 Tilemap fix #1635 2015-02-24 22:57:59 +00:00
Paul
4f747a1c00 Components - moving install to prototype
- This ensures the components are regsitered once per type
  instead of once per instance (which is duplicate work)
2015-02-22 20:44:11 -08:00
photonstorm
41e2fbff55 TilemapLayer no longer extends Image, but is a GameObject of its own. 2015-02-17 16:38:27 +00:00
photonstorm
8483eac6aa Removing all use of _cache from all Game Objects. 2015-02-16 17:22:51 +00:00
photonstorm
daf8440247 Tile.properties is now unique to that specific Tile, and not a reference to the Tileset index bound properties object. Tile.properties can now be modified freely without impacting other tiles sharing the same id (#1254) 2015-02-11 21:40:37 +00:00
photonstorm
29fd37aed7 Formatting update. 2015-02-11 05:19:00 +00:00
Mika Turunen
be3edd8437 Now the backwards compatibility is not broken
As implementation is leaning on 0.11.0 feature of Tiled, I made sure the earlier Tiled files that might be used are not going to break from this. Defaulting to empty string if the .type property is not defined by Tiled (for Tiled < 0.11.0), otherwise we use the provided value.
2015-02-10 14:54:14 +02:00
Mika Turunen
8a197b6023 Read ObjectLayer Objects .type property for Tiles
Why isn't the .type already read from the objects details as it's there? Latest release version of Tiled 0.11.0 has this field for Objects and it's quite extensively used by other frameworks.

Well, I need this and I suppose there are other people too who might be interested in having this in here too. Currently I go around this by creating a custom property of "type" and setting my value on it but that's just extremely silly.
2015-02-10 11:05:28 +02:00
Richard Davey
b66a0aa11a Merge pull request #1605 from mickez/tilemaplayer_scale
Added scaling capability to TilemapLayer
2015-02-09 20:02:48 +00:00
photonstorm
35a04b2f1e TilemapParser now supports Tiled 0.11 version maps which includes the rotation property on all Object types.
Tilemap.createFromObjects now checks for a `rotation` property on the Object and if present will set it as the Sprite.angle (#1433)
2015-02-08 23:25:41 +00:00
photonstorm
6d86952f98 JSDoc fix. 2015-02-08 21:57:09 +00:00
emailto@niklasberg.se
a0ea73a4cd Support for tiles rotated and/or flipped in Tiled 2015-02-08 21:21:39 +01:00
emailto@niklasberg.se
a70dd81a80 Support for tiles rotated and/or flipped in Tiled 2015-02-08 21:03:19 +01:00
Michael Rehn
bb2e263345 Changed to bracket on new line to follow the rest of the codes style 2015-02-07 21:31:17 +01:00
Michael Rehn
e600cb89b7 Added scaling capability to TilemapLayer via the setScale method 2015-02-07 19:48:44 +01:00
photonstorm
2ba6e0528e TilemapLayer.getTiles now returns a copy of the Tiles found by the method, rather than references to the original Tile objects, so you're free to modify them without corrupting the source (thanks @Leekao #1585) 2015-02-03 21:32:39 +00:00
Paul
ad9245caeb TilemapLayer - {missing changes} 2015-01-24 18:37:28 -08:00
Paul
818d5bcdcc Tilemaps - removed N-slice support
- Since N-slicing doesn't work in Safari, which is what the
  double-copy fix is for, it is simply removed.
2015-01-24 18:35:11 -08:00
Paul
4845c2054b TilemapLayer - quibbles
- Removed accidental change
2015-01-24 17:49:20 -08:00
Paul
11c78f11b0 TilemapLayer - Safari fix
- Changed default slice count to 1: this fixes yet another Safari-specific
  issue.
2015-01-24 17:43:08 -08:00
photonstorm
6d967b6545 Error in diffX and diffY calculation in Tilemap.paste (thanks @amelia410 #1446) 2015-01-20 10:49:15 +00:00
Paul
c361e6f535 TilemapLayer - fix for regression typo 2015-01-05 20:37:00 -08:00
Richard Davey
b4678b6b56 Merge pull request #1474 from nextht/remove-tw-and-th-init
Remove tw and th init
2015-01-05 11:15:28 +00:00
Paul
114d967272 TilemapLayer - quibbles
- Updated shiftCanvas usage for consistency with renderSetting access
2014-12-31 10:06:48 -08:00
Paul
76aa601d47 TilemapLayer rendering double-copy
- Memory optimization of delta-scroll shifting.
  - The copy canvas is shared between all TilemapLayers
  - The copy is done in segments to reduce the memory usage of the copy
  canvas. Currently this is a 1/4 ratio.

- Device has the feature (by browser) check to see if bitblt works
  - TilemapLayer will automatically enable the double-copy as needed
  - Device.whenReady can be used to override the device value
2014-12-31 09:54:37 -08:00
Paul
0ad21e3c84 Merge remote-tracking branch 'upstream/dev' into wip-tilelayer-safaribug 2014-12-30 23:07:55 -08:00
nextht
18b3a3cc5b Remove useless initilization for tw and th code
tw and th have been initialized twice, the first time is useless.
2014-12-20 17:45:27 +08:00
Paul
466b021ca0 TilemapLayer: Re-added secondary copy-canvas
- This change uses a secondary canvas and rectangle clearing instead of a
  'copy' composition on the same canvas. This should hopefully address
  the flickering issue in Safari and Safari Mobile
2014-12-12 00:26:49 -08:00
paul-reilly
ce603c3510 TilemapParser: fixed check for image collection 2014-12-10 22:42:17 +00:00
Paul
92a20a5f5f TileLayer - globalCompositionOperation set once
This might fix a safari issue; it also avoids repeatedly setting the
[same] composition operation and saving/loading context states.
2014-12-09 20:21:31 -08:00
Paul
47c49b18cf Tilemap - Tiled image size calculation
Addresses https://github.com/photonstorm/phaser/issues/1371 - where Tiled
used floor calculations and Phaser used round calculations.

There are no breaking changes with the demos; however, if there was code
that relied on behavior that _deviated_ from the defactor Tilemap behavior
then may be prone to "incorrect results" if using tileset images that are
not correctly aligned to tilesize multiples.

This also adds/corrects some warnings:
- A warning when the tileset size is not an even multiple (it was
  suppressed due to using `round` prior to the checks.
- A warning if loading an image changes the cols/rows of a Tileset
- A specific warning for Tileset Image Collections which are not yet
  supported
2014-11-26 19:50:07 -08:00
photonstorm
a2aa987920 jshint fixes 2014-11-11 01:09:57 +00:00
photonstorm
a2b7d339a2 Tilemap.createFromTiles will convert all tiles matching the given tile index (or an array of indexes) into Sprites. You can optionally then replace these tiles if you wish. This is perfect for games when you want to turn specific tiles into Sprites for extra control. The Sprites have an optional properties object which they can be populated with. 2014-11-11 01:05:59 +00:00
photonstorm
347978679d docs update 2014-11-11 01:05:59 +00:00
photonstorm
6d8fb60f77 Removed TilemapLayer.index getter as it incorrectly refereneced a property that didn't exist, breaking most demos. Couldn't see an obvious reason for the getter so restored previous property and tested all examples, and all run now (and faster too thanks to the rest of the changes made in TilemapLayer). 2014-11-08 14:50:00 +00:00
Paul
03af5e1582 TilemapLayer/Tileset - Documentation consistency updates for Phaser 2014-10-30 02:00:20 -07:00