Commit graph

90 commits

Author SHA1 Message Date
Richard Davey
ae08b9ac02 Text tab support working. Now to add varying tab sizing. 2015-07-07 23:31:44 +01:00
Richard Davey
b8cc4d9d53 Updated Text resolution handling. 2015-07-07 20:48:00 +01:00
photonstorm
9548fb9856 Final textBounds updates. 2015-07-07 15:16:23 +01:00
photonstorm
a89d48b9a6 Text.autoRound allows you to control if the text is allowed to render at sub-pixel coordinates or not. Set to true to round the coordinates, often eliminating anti-aliasing from certain font types (#1867) 2015-07-02 13:39:59 +01:00
Richard Davey
2b7666e22d Added toString to the constructor parameter. 2015-07-01 23:37:48 +01:00
photonstorm
8356aacaa8 Trying out new Text pivot and mute handling. 2015-06-24 19:57:40 +01:00
photonstorm
a69c156526 The Text Bounds is a rectangular region that allows you to align your text within it, regardless of the number of lines of text or position within the world. For example in an 800x600 sized game if you set the textBounds to be 0,0,800,600 and text alignment to 'left' and vertical alignment to 'bottom' then the text will render in the bottom-right hand corner of the game, regardless of the size of font you're using or the number of lines in the text itself.
Set the Style properties `boundsAlignH` and `boundsAlignV` or adjust them via the Text setters to change the alignment.

It works by calculating the final position based on the Text.canvas size, which is modified as the text is updated. Some fonts have additional padding around them which you can mitigate by tweaking the Text.padding property.

Setting a textBounds _doesn't_ update the wordWrapWidth, so be aware of the relationship between the two.

Call this method with nothing defined for any of the parameters to reset an existing textBounds.

#1824
2015-06-17 17:18:04 +01:00
photonstorm
0258245f12 Phaser.Text no longer extends PIXI.Text but replaces it entirely. Phaser.Text now natively extends a Phaser Sprite, meaning it can be enabled for physics, damaged, etc. 2015-06-17 13:21:28 +01:00
photonstorm
8290e8c371 Text.setShadow has two new optional parameters: shadowStroke and shadowFill. These allow you to set if the drop shadow is applied to the Text stroke, the Text fill or both of them (thanks @qdrj #1766)
Text.shadowStroke and Text.shadowFill allow you to toggle if the drop shadow is applied to the Text stroke or fill independently.
2015-04-27 16:22:36 +01:00
photonstorm
85c8f60d7c Removed 'global' component arrays. 2015-03-23 19:19:07 +00:00
photonstorm
b7b622a556 Text style has a new optional property: backgroundColor which is a Canvas fill style that is set behind all Text in the Text object. It allows you to set a background color without having to use an additional Graphics object.
Text.lineSpacing can now accept negative values without cutting the bottom of the Text object off. The value can never be less than the height of a single line of text.

Text.lineSpacing is no longer applied to the first line of Text, which prevents text from being cut off further down the Text object.
2015-03-23 16:12:23 +00:00
photonstorm
1486e166bd Added physicsType property. 2015-03-23 15:04:27 +00:00
photonstorm
cb9ef4f12e Text.padding specifies a padding value which is added to the line width and height when calculating the Text size. ALlows you to add extra spacing if Phaser is unable to accurately determine the true font dimensions (#1561 #1518) 2015-03-19 01:54:14 +00:00
Richard Davey
7eb73e99a8 Merge pull request #1648 from pnstickne/wip-components-docs
Component documentation
2015-03-01 10:46:55 +00:00
Paul
4de95c09b5 Component documentation
- Required changes for documentation to show up correctly
  - Uses multiple @extends, which currently [mostly] works in jsdoc
    and like closure compiler
2015-02-28 23:00:17 -08: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
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
ae7a1fda05 Optimised preUpdate callbacks. 2015-02-25 02:49:50 +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
58d37b51fe Fixed canvas destroy if undefined. 2015-02-18 14:54:11 +00:00
photonstorm
167bbde8d4 Game Objects all now using the new Components mixins. 2015-02-17 06:00:41 +00:00
photonstorm
8483eac6aa Removing all use of _cache from all Game Objects. 2015-02-16 17:22:51 +00:00
Richard Davey
b560af992f Merge pull request #1375 from pnstickne/wip-text-consistency
Text - font components can be specified as part of "style"
2015-02-11 15:06:48 +00:00
photonstorm
def662f28f Text.setShadow has had the default color value changed from rgba(0,0,0,0) to rgba(0,0,0,1) so it appears as a black shadow by default - before the alpha channel made it invisible. 2014-12-02 09:03:55 +00:00
Richard Davey
81f356c235 Merge pull request #1386 from pnstickne/wip-docs-1130
Assorted documentation/consistency updates
2014-12-01 12:07:10 +00:00
Paul
d15037e283 Event-Signal object count optimization
There are a bunch of signals added for Sprites; more when input is
enabled. However, very few of these signals are ever actually used. While
the previous performance update related to Signals addressed the size of
each Signal object, this update is to reduce the number of Signal objects
as used by the Events type.

As a comparison the "Particle: Random Sprite" demo creates 3200+ Signals;
with this change there less than 70 signals created when running the same
demo. (Each Event creates at 8 signals by default, and there is an Event
for each of the 400 particles.) While this is an idealized scenario, a
huge amount (of albeit small) object reduction should be expected.

It does this by creating a signal proxy property getter and a signal
dispatch proxy. When the event property (eg. `onEvent`) is accessed a new
Signal object is created (and cached in `_onEvent`) as required. This
ensures that no user code has to perform an existance-check on the event
property first: it just continues to use the signal property as normal.

When the Phaser game code needs to dispatch the event it uses
`event.onEvent$dispath(..)` instead of `event.onEvent.dispatch(..)`. This
special auto-generated method automatically takes care of checking for if
the Signal has been created and only dispatches the event if this is the
case. (If the game code used the `onEvent` property itself the event
deferal approach would be defeated.)

This approach is designed to require minimal changes, not negatively
affect performance, and reduce the number of Signal objects and
corresponding Signal/Event resource usage.

The only known user-code change is that code can add to signal (eg.
onInput) events even when input is not enabled - this will allow some
previously invalid code run without throwing an exception.
2014-11-30 21:39:25 -08:00
Paul
dab8772de0 Documentation - consistency updates
- Updated `readOnly` doclet to `readonly`

- `array` refined to `type[]`, where such information was immediately
determinable.

- Updated {Any}/{*} to {any}; {...*} is standard exception

- Udated {Object} to {object}
2014-11-30 04:03:35 -08:00
Paul
83cbbf1d21 Text - font component cleanup
Some minor cleanup of font component handling and comments.

Also adds a warning if an "unparsable font" string is encountered. Might
save someone some trouble.
2014-11-28 03:50:52 -08:00
Paul
bf3d5aa22e Text - consistency updates
Added `cssFont`, `fontStyle`, and `fontVariant` properties for better
consistency and control.
2014-11-28 02:56:44 -08:00
Paul
8eb7594b29 Text - font size/weight can be specified as style
Fulfills: https://github.com/photonstorm/phaser/issues/1370

This allows `fontSize` and `fontWeight` to be specified as part of the
style as supplied to the Text constructor (and `setStyle` method). In
addition the `fontStyle` and `fontVariant` properties can also be set -
although these are not exposed later.

This also fixes edge cases that could be caused if `Text#fontSize` was
used without `Text#fontWeight`, where the applied style defaults would be
overwritten/reset.
2014-11-28 02:20:18 -08:00
Paul
5fbbeca7ab Text - documentation updates 2014-11-28 00:12:10 -08:00
photonstorm
e86f00eb55 Text.lineSpacing works correctly again. Before no space was added between the lines (thanks @intimidate #1367 and @brejep #1366) 2014-11-25 17:06:17 +00:00
Tim van den Eijnden
990867547e fix issue with lineSpacing, no space was added between the lines. The complete text moved down instead 2014-11-25 16:45:29 +01:00
photonstorm
1068563914 jsdoc fixes. 2014-11-25 14:15:55 +00:00
spayton
a942a03631 Texture width is recalculated larger on subsequent call to updateText() when text has a stroke thickness > 1
In function override Phaser.Text.prototype.updateText(), don't include this.context.lineWidth in width calculation as it's already incorporated by this.style.strokeThickness.
2014-10-28 11:48:57 +00:00
photonstorm
d22f2bd89b Small fix for Text wordWrapping #1247 2014-10-23 16:03:29 +01:00
photonstorm
b56c3bf54e jshint fixes 2014-10-22 22:49:20 +01:00
photonstorm
1bc1d2eb94 Fixed Text class for Pixi v2 changes. 2014-10-22 22:35:21 +01:00
photonstorm
7f196a01e7 Text.addColor allows you to set specific colors within the Text. It works by taking a color value, which is a typical HTML string such as #ff0000 or rgb(255,0,0) and a position. The position value is the index of the character in the Text string to start applying this color to. Once set the color remains in use until either another color or the end of the string is encountered. For example if the Text was Photon Storm and you did Text.addColor('#ffff00', 6) it would color in the word Storm in yellow.
Text.clearColors resets any previously set colors from `Text.addColor`.
2014-09-24 17:10:02 +01:00
photonstorm
dd74e3b0b4 Changing any of the Text properties such as font, lineSpacing and fontSize on a Text object that wasn't already on the display list would cause an updateTransform error. Parent is now checked first in all setters. 2014-09-24 01:10:36 +01:00
photonstorm
d18f523d93 jsdoc fixes. 2014-09-18 16:58:25 +01:00
photonstorm
7d9a4f4100 Phaser.Text wouldn't render the text to its local canvas if you passed the text on the constructor and didn't add it to the display list. If a string is given it now updates the local canvas on creation. 2014-09-04 02:18:12 +01:00
Richard Davey
fe0c03d5d7 Phaser.Text.destroy will now destroy the base texture by default (#1162) 2014-09-03 22:34:10 +01:00
photonstorm
fa45d7feff Events.onDestroy is a new signal that is dispatched whenever the parent is being destroyed. It's dispatched at the start of the destroy process, allowing you to perform any additional house cleaning needed (thanks @jonkelling #1084)
Group.onDestroy is a new signal that is dispatched whenever the Group is being destroyed. It's dispatched at the start of the destroy process, allowing you to perform any additional house cleaning needed (thanks @jonkelling #1084)
2014-08-28 02:56:06 +01:00
photonstorm
d10dea27b0 Pixi updated worldTransform from an Array to an Object and Phaser Image, BitmapText, Text and Graphics were still using array access to populate the world property, giving it incorrect results (thanks @alvinsight) 2014-07-15 22:44:02 +01:00
photonstorm
e85bbf8bc5 Text.updateText now sets the lineCap to round to avoid occassional font glitching issues in Chrome. 2014-04-28 15:17:47 +01:00
photonstorm
0b1fb5a637 Destroying an object with an input handler during its onDown event would throw Signals dispatch errors (thanks @jflowers45, fix #746)
InputHandler._setHandCursor private var wasn't properly set, meaning the hand cursor could sometimes remain (during destroy sequence for example)
All Game Objects have a new property: destroyPhase (boolean) which is true if the object is in the process of being destroyed, otherwise false.
The PIXI.AbstractFilter is now included in the Phaser Pixi build by default, allowing for easier use of external Pixi Filters.
2014-04-22 01:43:22 +01:00
nickryall
5f7d38e9fd Rounded lineJoins for text stroke 2014-04-01 09:00:35 +13:00
nickryall
772d9ca9f2 Renable input on Phaser.Image fix 2014-04-01 08:54:08 +13:00
Christian Wesselhoeft
bdbf2783ad Fix jshint issues in src/gameobjects 2014-03-25 14:56:05 -07:00