Commit graph

3096 commits

Author SHA1 Message Date
Pete Baron
a8405bd066 add comment 2016-06-13 17:26:33 +12:00
Pete Baron
57a6245f25 Made a copy of Phaser.TilemapLayer which instead extends PIXI.Tilemap, then added functions to build a batch list of tile source and destination coordinates (instead of drawing them directly onto a Canvas). This maintains all the existing Phaser functionality in regards to tile map decoding and interpretation, and also provides maximum performance from the PIXI component by using a TRIANGLE_STRIP to render everything as a single batch job. 2016-06-13 17:25:50 +12:00
Pete Baron
94d49f1196 Add GL variant of the Tileset.draw function for new approach to WebGL tile drawing (utilising most of the existing Phaser code unchanged) 2016-06-13 17:13:13 +12:00
Pete Baron
0904e386de Use firstgid (TODO: assumes tileset 0 currently, needs to calculate the correct tileset) to fix the 'out by one' tilemap example errors.
Handle empty VBO case, and make sure we only drawArrays the correct number of vertices (to fix the large corrupt block in the top-right corner of many example demos).
2016-05-26 14:13:07 +12:00
Pete Baron
0dd3610ee4 Minor optimisation in TilemapLayerGL to remove unnecessary loop. 2016-05-26 14:10:45 +12:00
Pete Baron
a9bf339efd Fully working sci-fly demo using a single gl draw to blit all of the tiles at once. Theoretically extremely fast (requires testing). Works here in FireFox and Chrome at 60 fps on an i7 4770 with Nvidia 780 GTX drawing typically 1989 tiles per frame. 2016-05-23 21:09:13 +12:00
Pete Baron
1b7eaadd06 First (nearly) working batch drawing test. Instead of pushing rectangles as pairs of triangles individually, this version creates a vertex buffer object for all visible tile rectangles, with degenerate triangles separating each one from the next. The drawing is done by a single call to gl.drawArrays.
Bizarrely, this version still chokes in Firefox, implying that the previous demo's horrible performance was not down to the GPU blocking as the rectangles are sent to it.

The test is not fully working because it does not scroll the drawing position. So instead of the map moving when you hit a scroll boundary, it simply stops drawing the top or left edges as the scroll region moves away from the visible window.  It's an easy fix, but I think I'll leave it until I find out exactly why Firefox still chokes on this demo.

Progress text file updated with latest experiments and progress today.
2016-05-23 17:48:54 +12:00
Pete Baron
5c6ad9cbcb Fix double subtraction error. 2016-05-13 14:34:24 +12:00
Pete Baron
e396c266b8 Use the correctly scaled scrollX, scrollY parameters for the scroll offsets.
This makes the layers in "blank tilemap" example work properly (you'll need to click the 3rd tile in the palette before drawing becomes visible - that's next up)
2016-05-13 14:13:51 +12:00
Pete Baron
5be5ddba25 Protect against zero and negative indexes (-1 is used in e.g. "blank tilemap" example). 2016-05-13 14:06:58 +12:00
Pete Baron
49b3d1a57a Temporary modification to force webgl renderer without needing to edit all the example files. 2016-05-13 14:06:08 +12:00
Pete Baron
e0008793bd Prepare Phaser.Tilemap for testing other examples/tilemaps with the TilemapLayerGL code.
Ensure that TilemapLayerGL is treated as a valid layer the same as TilemapLayer.

TODO: I've hardwired the PIXI TilemapLayerGL test flag (pixiTest) to be 'on' unless otherwise specified... need to turn this off before final commits!
2016-05-13 12:24:55 +12:00
Pete Baron
a98d0e8e70 First pass of 'clean-up': correcting comments, removing unused code 2016-05-13 12:06:18 +12:00
Pete Baron
4cfcb3b7bd Implemented _renderMode switch and _renderVisibleTiles functionality. This speeds up the sci-fly demo hugely. 2016-05-13 11:37:33 +12:00
Pete Baron
0855e59972 Added _renderMode to switch between full-map redrawing and visible screen redrawing modes. 2016-05-13 11:36:12 +12:00
Pete Baron
5e97f10c86 Remove un-needed mixin components leaving only FixedToCamera (not sure about this one). Move this.fixedToCamera after the Core.init call which creates the underlying core components required. Add temporary instant return from shiftCanvas in case that was being called and contributing to the slow-down (probably not). 2016-05-05 17:00:22 +12:00
Pete Baron
ef4143136e Use this.x, this.y as scrolling offsets when rendering each tile. 2016-05-05 16:57:55 +12:00
Pete Baron
69abe492cc Modified Phaser.Tilemap and PIXI.Tilemap to support the new Phaser.TilemapLayerGL objects.
The PIXI file has a reverse dependency on Phaser for it's 'layer' parameter which contains a Phaser.Tilemap (which holds the map data).  The other changes adapt it to the new data source (previously this expected a raw JSON object encoded like the Mario.json map is).

The Phaser file now keeps a reference to the data parsed from the original map, and adds a branch in createLayer to build a TilemapLayerGL instead of a TilemapLayer.
2016-05-05 15:58:03 +12:00
Pete Baron
ad04676980 New class: duplicate of Phaser.TilemapLayer modified to access the new PIXI.Tilemap WebGL based tile renderer.
This is just the first test which actually produces some visible output (the map is drawn for the "sci fly" demo example, if you adjust line 27 of that source file to: layer = map.createLayer(0, undefined, undefined, undefined, true);
The new terminal "true" parameter instructs Phaser.Tilemap.createLayer to create a TilemapLayerGL object instead of the usual Phaser.TilemapLayer.
2016-05-05 15:52:26 +12:00
photonstorm
45118e7a60 Docs fix. 2016-05-04 23:34:15 +01:00
Pete Baron
eb77949f63 Strip down PIXI.Tilemap to remove all unused code.
Add very simple tilemap render function to draw every layer, every tile, for the tiles provided.
Link to the TilemapShader and get the whole thing working.
2016-05-05 10:29:51 +12:00
Pete Baron
9deb07c3aa Modify this shader to draw a simple textured rectangle using a two-tri strip, extremely quickly due to simplicity. 2016-05-05 10:28:12 +12:00
photonstorm
1adece490a Docs update. 2016-05-04 02:02:13 +01:00
photonstorm
7afe087c3d Docs fix. 2016-04-29 17:46:44 +01:00
photonstorm
7332dd8028 Custom WebGL Tilemap renderer POC displaying textures. It's a start. 2016-04-28 00:18:09 +01:00
photonstorm
16378713b4 JSDocs update (#249) 2016-04-27 12:57:41 +01:00
photonstorm
d55b0c9e51 Tilemap update. 2016-04-27 03:38:07 +01:00
photonstorm
b10c8858c3 Tilemap shader WIP. 2016-04-27 03:02:13 +01:00
photonstorm
f494c867c7 Fixed an issue in the Arcade Physics overlap method where it would only detect overlaps up to the max bias threshold and no further (thanks @rgk #2441)
The Arcade Physics overlap method would return false if two bodies were overlapping but neither had any velocity (i.e. they were embedded into each other)
2016-04-25 11:38:51 +01:00
Richard Davey
74d52dd327 Merge pull request #2443 from drhayes/dev
Add a "shakeIntensity" property to Camera.
2016-04-23 04:34:08 +01:00
photonstorm
6bc93de7a5 Preparing for 2.4.8 dev. 2016-04-23 04:32:47 +01:00
David Hayes
fb709fe728 Add a "shakeIntensity" property to Camera.
This would allow tweening the intensity of the Camera shake over the
lifetime of the shaking.
2016-04-22 19:53:52 -05:00
photonstorm
a29cc64932 Phaser 2.4.7 Final. 2016-04-22 15:15:28 +01:00
photonstorm
002d6250a8 Docs update. 2016-04-21 00:48:54 +01:00
photonstorm
3d6b1a3b7e Stopped the Camera Shake effect from changing the World position, as it screws up Arcade Physics, Sprite deltas and some input handling. Instead moved the effect to be render applied only. On Canvas it updates the context.setTransform call, and on WebGL the renderSession offset property. 2016-04-19 04:12:58 +01:00
photonstorm
62d135cf1f Small tidy-up. 2016-04-19 03:39:04 +01:00
photonstorm
7d9c817373 Dragging a Sprite while the camera was moving would slowly cause the Sprite position to become out of sync the further the camera moved. A Sprite being dragged now tracks the camera position during the drag update and adjusts accordingly (thanks @jeroenverfallie #1044) 2016-04-19 01:54:24 +01:00
photonstorm
628dd1c420 P2.Body.offset is now used and applied to the Sprite position during rendering. The values given are normal pixel values, and offset the P2 Body from the center of the Sprite (thanks @Mourtz #2430) 2016-04-18 20:57:41 +01:00
photonstorm
a2d145a43d When the Loader loads audio via the Audio tag, instead of Web Audio, it used to use Phaser.GAMES[_this.game.id].load as the callback handler, which would stop it from working if you had multiple Loaders set-up within Phaser. It now uses a local reference to _this instead (thanks @SBCGames #2435) 2016-04-18 16:44:28 +01:00
photonstorm
41f81d39b7 jsdocs update (and removed isCircle switch) 2016-04-18 16:17:47 +01:00
photonstorm
257a22b170 When loading Video with the asBlob argument set it now uses a 'blob' type for the XHR loader, and doesn't cast the resulting file as a Blob upon load. This fixes loading videos as blobs on Chrome for Android (thanks @JuCarr #2433) 2016-04-18 16:17:27 +01:00
photonstorm
41add1b4bf Phaser 2.4.7 RC1. 2016-04-14 13:23:44 +01:00
photonstorm
ac4acfb912 Removed Arcade Physics Circle support (now in its own branch) ready for 2.4.7 release. 2016-04-14 13:23:28 +01:00
photonstorm
4d8753e9ce Tidying up for 2.4.7. 2016-04-14 12:57:05 +01:00
photonstorm
aad499b025 Tidying up the code base for 2.4.7. 2016-04-14 12:43:10 +01:00
photonstorm
5221bfd5da You can now pass in your own Canvas element to Phaser and it will use that instead of creating one itself. To do so you must pass a Game Configuration object to Phaser when you instantiate it, and set the canvas property of the config object to be the DOM element you wish to use, i.e.: { canvas: document.getElementById('yourCanvas') } (thanks @Friksel #2311) 2016-04-14 11:57:10 +01:00
Lewis Pollard
719b4bb7f6 Alter BitmapText to use toString on text parameter in constructor
The BitmapText property accessor for the text property uses toString on the value passed in, meaning Numbers can be passed in as the text value with no problem. However, passing a Number into the constructor results in the following exception as it isn't implicitly converted to a string in a similar manner.

phaser.js:71890 TypeError: text.substr is not a function
    at Phaser.BitmapText.updateText (http://localhost/phaser/build/phaser.js:56283:21)
    at new Phaser.BitmapText (http://localhost/phaser/build/phaser.js:56034:10)
    at Phaser.GameObjectFactory.bitmapText (http://localhost/phaser/build/phaser.js:46318:26)
    at Object.Boot.create (http://localhost/phaser/:46:34)
    at Phaser.StateManager.loadComplete (http://localhost/phaser/build/phaser.js:29240:35)
    at Phaser.Loader.finishedLoading (http://localhost/phaser/build/phaser.js:71446:25)
    at Phaser.Loader.processLoadQueue (http://localhost/phaser/build/phaser.js:71403:18)
    at Phaser.Loader.asyncComplete (http://localhost/phaser/build/phaser.js:71476:14)
    at Phaser.Loader.xmlLoadComplete (http://localhost/phaser/build/phaser.js:72413:14)
    at .<anonymous> (http://localhost/phaser/build/phaser.js:72236:34)

This simply mimics the logic in the property accessor by running toString on the text value and using an empty string if null to allow Numbers to be passed into the constructor.
2016-04-13 15:24:29 +01:00
Richard Davey
358cc6b8d0 Merge pull request #2428 from EJanuszewski/radToDeg-typo
Fix typo in Math radToDeg description
2016-04-13 14:18:18 +01:00
photonstorm
f4277efc20 Alternative snooker-ball like collision test. 2016-04-11 16:43:17 +01:00
photonstorm
a193ad557e Fixed jsdocs #2418 2016-04-11 08:55:24 +01:00