Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411275 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 05:41:08 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsHaxeFlixel Tutorials
Pages: [1]
Print
Author Topic: HaxeFlixel Tutorials  (Read 2454 times)
laxa88
Level 0
*


View Profile
« on: March 14, 2015, 11:52:57 PM »

I discovered HaxeFlixel recently, and love it very much. The documentation is a little lacking and I struggled to use a lot of the API, hence I started a devblog to keep track of my knowledge and help people who are starting out in HaxeFlixel game development. Once I've learned enough about a particular topic, I'll write up a tutorial for it.

Do check it out, I'd love to hear any suggestions and/or comments on it. I'm still a beginner in Haxe so I apologise if my tutorials are inaccurate -- will fix if I'm notified. Smiley

http://coinflipstudios.com/devblog/

Here's a list of all the articles on the blog right now, for easier access:

Introduction to HaxeFlixel – Part 0: About HaxeFlixel
Introduction to HaxeFlixel – Part 1: Haxe Setup
Introduction to HaxeFlixel – Part 2: Editor Setup
Introduction to HaxeFlixel – Part 3: Hello World

My First Game – Part 1: Mental Preparation
My First Game – Part 2: Game Design
My First Game – Part 3: Pong – Setup
My First Game – Part 4: Pong – Paddle
My First Game – Part 5: Pong – Paddle Movement
My First Game – Part 6: Pong – Second Paddle
My First Game – Part 7: Pong – The Ball
My First Game – Part 8: Pong – Score Text
My First Game – Part 9: Pong – Sound
My First Game – Part 10: Pong – Post Mortem

HaxeFlixel Study – FlxTeroids, Part 1: Project Setup
HaxeFlixel Study – FlxTeroids, Part 2: Design
HaxeFlixel Study – FlxTeroids, Part 3: Code Study
HaxeFlixel Study – FlxTeroids, Part 4: Code Study (cont’d)
HaxeFlixel Study – FlxTeroids, Part 5: Code Study (cont’d)

HaxeFlixel Tutorial – Debugging
HaxeFlixel Tutorial – Loading Tile Map Data
HaxeFlixel Tutorial – Parsing CSV Map Data
« Last Edit: March 16, 2015, 07:11:24 PM by laxa88 » Logged
Mixer
Level 1
*


I've never really known what to put here.


View Profile WWW
« Reply #1 on: March 15, 2015, 03:26:34 AM »

Following this. Been using haxeflixel for my game, and it has been great. It never gets in your way, atleast for me. I might post some tips sometime.
Logged

My twitter is @5Mixer.
I'm currently making a dungeon game, check it out :D
https://forums.tigsource.com/index.php?topic=59139.0
Mixer
Level 1
*


I've never really known what to put here.


View Profile WWW
« Reply #2 on: March 16, 2015, 01:38:37 AM »

These may be obvious/not useful.

1) Tryhaxe is a website that compiles have code online. It is good for making code that helps people on forums, as you can quickly test if it compiles.

2) Extending classes allows for extended behaviour. FlxSprite is obvious, but everything from animations, the weapons class, and the effects class can all be extended.

3) Polymorphism allows for you to have a base item class and then all of your classes can extend from that. You can store these classes in a FlxGroup of your item class.

3) When a class expects you to give a callback that has no arguments, but you want to pass arguments to that class, give it an anonymous function with a function call inside.

For example, the FlxButton stupidly wants to call a function with no arguments. But what if there are 5 buttons, in a shop, to buy different items? Well of course you don't want a buyTrophy, buyGem, buyDiamond.... method, you just want one method that takes an argument of the item. But flxButton doesn't want an item! What do you do?

callback = function() { buyItem(trophy); }

//Next button...
callback = function() { buyItem(diamond); }

Now you only need one buy method!

4) Callbacks are surprisingly your friend.

5) If you are doing something expensive in your update method (like I was, resetting large inventories every frame) that is setting something else to a variable. Like a labels text to a variable, instead of setting it every frame, make a method that is automatically called when ever a certain variable is changes. Shown below (Pseudo code, won't compile)

//Before, bad.
score:FlxText
myScore:Int (get,set)miscode)= 900000;

update(){
     score.text = myScore;
}

//After, good.
score:FlxText
myScore:Int = 900000;

update(){
    //Nothing
}

function set_myscore(newScore:Int){
    score.text=newScore;
}

Hope these were useful. A lot of these were learnt when making an inventory like one in terror or minecraft in haxeflixel.
These might be obvious too you, but maybe not others.
Smiley

Edit: I kind of rushed this, if you don't understand anything, post.
Logged

My twitter is @5Mixer.
I'm currently making a dungeon game, check it out :D
https://forums.tigsource.com/index.php?topic=59139.0
laxa88
Level 0
*


View Profile
« Reply #3 on: March 16, 2015, 08:02:12 AM »

@Mixerman123: Thanks for the reply and for the awesome tips!

I especially like the tip on having an anonymous function with another function call inside. Nifty.

I find myself struggling more with the somewhat vague Haxe error messages. Perhaps that's because I am still new to Haxe and its syntax, but so far most of my mistakes are on HaxeFlixel-related API rather than the language itself. I still have much to learn. Smiley

I came across this blog post which has helped me a few times, perhaps it'd be of use to other beginners as well: http://www.joshuagranick.com/2012/10/05/glossary-of-haxe-error-messages/
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic