Skip to content

Instantly share code, notes, and snippets.

@ibilon
Created October 20, 2013 08:10
Show Gist options
  • Save ibilon/7066298 to your computer and use it in GitHub Desktop.
Save ibilon/7066298 to your computer and use it in GitHub Desktop.
import com.haxepunk.HXP;
import com.haxepunk.Entity;
import com.haxepunk.graphics.Text;
import com.haxepunk.graphics.Image;
import com.haxepunk.utils.Input;
class Paper extends Entity
{
var stringIterator:Int;
var showText:Text;
var storedString:String;
public function new(paper:String)
{
super(50, 50, Image.createRect(300, 400, 0xFFFFFF));
showText = new Text("", 0, 0, 300, {color: 0, wordWrap: true});
HXP.scene.addGraphic(showText, 0, 50, 50);
storedString = paper;
stringIterator = 0;
}
public override function update()
{
super.update();
handleInput();
}
public inline function handleInput()
{
if (Input.pressed(-1))
{
showText.text += storedString.charAt(stringIterator);
stringIterator += 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment