forked from ZaaLabs/PushButtonEngine
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added wrapper class for Starling TouchEvents to play nice with PB eve…
…nt dispatcher Added TextFieldRenderer. Fixed color property in SpriteSheetRenderer (and subclasses).
- Loading branch information
1 parent
ff4ca4d
commit b320f5f
Showing
5 changed files
with
175 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.starling.events | ||
{ | ||
import flash.events.Event; | ||
|
||
/** | ||
* Intermediate class to convert Starling Events to flash events, in order to play nice with PushButton. | ||
* | ||
* TODO - get starling to use flash.events. | ||
*/ | ||
public class StarlingTouchEvent extends Event | ||
{ | ||
|
||
public static const TOUCH_DOWN:String = "touch_down"; | ||
|
||
public function StarlingTouchEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) | ||
{ | ||
super(type, bubbles, cancelable); | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.starling.rendering2D | ||
{ | ||
import com.pblabs.engine.entity.PropertyReference; | ||
import com.starling.rendering2D.DisplayObjectRenderer; | ||
import starling.display.DisplayObject; | ||
import starling.text.TextField; | ||
|
||
/** | ||
* Static text field, rendered to the GPU. Once the text is set, either through the text property or the textReference, it cannot be changed. | ||
*/ | ||
public class TextFieldRenderer extends DisplayObjectRenderer | ||
{ | ||
public var textReference:PropertyReference; | ||
public var text:String; | ||
public var fontName:String = "Verdana"; | ||
public var fontSize:uint = 12; | ||
public var bold:Boolean = false; | ||
public var color:uint = 0x000000; | ||
public var textWidth:int = 200; | ||
public var textHeight:int = 30; | ||
public var autoScale:Boolean = false; | ||
public var border:Boolean = false; | ||
|
||
public var textField:TextField; | ||
|
||
override protected function onAdd():void | ||
{ | ||
if ( text != null ) | ||
addTextField(text); | ||
|
||
super.onAdd(); | ||
} | ||
|
||
override public function advanceTime(deltaTime:Number):void | ||
{ | ||
if ( textReference != null && owner.getProperty(textReference) as String != text) | ||
{ | ||
addTextField(owner.getProperty(textReference) as String); | ||
} | ||
super.advanceTime(deltaTime); | ||
} | ||
|
||
private function addTextField(_text:String):void | ||
{ | ||
text = _text; | ||
textField = new TextField( textWidth, textHeight, text, fontName, fontSize, color, bold ); | ||
textField.autoScale = autoScale; | ||
textField.border = border; | ||
if ( this.displayObject != null ) //remove old text | ||
scene.remove(this); | ||
|
||
this.displayObject = textField as DisplayObject; | ||
scene.add( this ); | ||
} | ||
|
||
} | ||
|
||
} |