crowso
crowso

Reputation: 2087

flixel hello world not working

This is the code that i compiled using mxmlc the free flex sdk. It compiled and i ran it. Helloworld not displayed

 package
    {
        import org.flixel.*;

        public class PlayState extends FlxState
        {
            override public function create():void
            {
                add(new FlxText(0,0,100,"Hello, World!")); //adds a 100x20 text field at position 0,0 (upper left)
            }
        }   

    }

Expected output is = HelloWorld. But is not displayed

Upvotes: 0

Views: 365

Answers (2)

xhunterko
xhunterko

Reputation: 49

Try this instead:

package  
{   
import org.flixel.*;    

    public class HelloWorld extends FlxState
    {

        private var title_text:FlxText;     

        public function HelloWorld() { }        

        override public function create():void
        {           
            title_text = new FlxText(20, 0, 300, 'Lunarium');
            title_text.setFormat(null, 50, 0xffffffff, "center");
            add(title_text);                
        }

        override public function update():void
        {
            if(FlxG.keys.X)
            {
                FlxG.fade(0xff131c1b, 1, onFade);   
            }           
            super.update();          
        }       

        protected function onFade():void
        {       
            //FlxG.switchState(new SmallPlay2());
        }
    }   
} 

There are plenty of tool tips to help you figure out what the different settings mean. I found flixel rather easy to use coming from a Multimedia Fusion 2 background.

Enjoy!

Upvotes: 1

Joe Osborn
Joe Osborn

Reputation: 1155

You'll need to provide an FlxGame subclass too. It may be easiest for you to take an existing Flixel project that works out of the box such as AdamAtomic's HelloWorld and modify it to suit your needs.

Upvotes: 3

Related Questions