Flixel for Monkey

Monkey Forums/User Modules/Flixel for Monkey

devolonter(Posted 2012) [#1]
Description:
This framework is a port of AS3 flixel to the Monkey language. The port is translated from flixel v2.55 written by Adam "Atomic" Saltsman.

Website:
http://devolonter.github.com/flixel-monkey/

Repository on GitHub:
https://github.com/devolonter/flixel-monkey

Original flixel website:
http://flixel.org/

Flixel documentation:
http://flixel.org/docs/ (API Flixel for Monkey is very similar to the original flixel API)

On any errors report by email or in the tracker: https://github.com/devolonter/flixel-monkey/issues


devolonter(Posted 2012) [#2]
Nightly build update is available. The main feature of this version is the support of reflection.

List of changes:
* The following interfaces are removed: FlxClass, FlxBasicSetter, FlxBasicInvoker, FlxBasicComparator.

* The constructor of the class FlxGame accepts ClassInfo by the third parameter. For example, New FlxGame (640, 480, GetClass ("HelloWorldState"))

* There is no need to override GetClass method of the FlxState class

* FlxGroup.SetAll accepts the string field name (properties are also supported) by the first parameter

* FlxGroup.CallAll accepts the string name of the function by the first parameter

* FlxGroup.Sort accepts the string field name by the first parameter

* All globals ClassObject:Object declared inside each class are automatically initialized at the time of creating an instance of the game.

Important! ClassObject must have an Object type and before using should be upcast to ClassInfo. For example, FlxGroup.Recycle (ClassInfo (FlxSound.ClassObject)). You can also use the following approach: FlxGroup.Recycle (GetClass ("FlxSound")), but it may not be very good for performance.

You can download nightly build here: http://devolonter.github.com/flixel-monkey/downloads.html

Updated bananas can be found here: https://github.com/devolonter/flixel-monkey-bananas/tree/nightly


jowli(Posted 2012) [#3]
I have been using this for a few weeks now, it is really good. Thanks for your efforts.


FelipeA(Posted 2012) [#4]
I've published two small games using flixel-monkey one on flash an html5 and the other on flash, android and blackberry playbook and in all platforms runs very smooth rendering a lot of particles and sprites and at all time doing collision detection.

Really great work and it's great you've added reflection!
I am thinking on making a small tutorial on flixel-monkey for you to add at the tutorial page.


devolonter(Posted 2012) [#5]
You are welcome! :) Thank you for feedback and support!

I am thinking on making a small tutorial on flixel-monkey for you to add at the tutorial page

I think the idea about making tutorial is really great. Thanks! I don't think I could make one in the nearest future. Right now I'm working on framework improvement.


devolonter(Posted 2012) [#6]
Nightly build update is available.

List of changes:
* Added resolution policies. These allow you to easily control the behavior of the screen when you change the size of the device. The following resolution policies are available: FillResolutionPolicy (by default), RatioResolutionPolicy, FixedResolutionPolicy and RelativeResolutionPolicy. In order to set the resolution policy, use the FlxG.SetResolutionPolicy:Void(resolutionPolicy:FlxResolutionPolicy).

* FlxGame.useVirtualResolution field and FlxG.FullScreen function have been removed. Use resolution policies

* The cursor and sound tray are no longer part of the main camera. Thus the zoom of the camera and its position doesn't act on them. Now they are the part of the screen and only valid screen size and global device scale factor act on them.

* Fixed the cursor scale bug

* Fixed work of a few the buttons in several cameras

Resolution policies demo | Source code

The next step is to port FlxSave and implement cross-platform FlxPreloader. After this version v1.0a4 will be released.


Sledge(Posted 2012) [#7]
That ratio policy is golden!


richicon(Posted 2012) [#8]
I'm new to Monkey, and programming in general, so please forgive me if this is a obvious question.

Does Flixel for Monkey run Flixel code 'as-is', and also support Flixel libs like Flixel Power Tools?

So - for example; if I found an example platform game framework coded in Flixel - would it run straight away in Flixel for Monkey or would it need a lot of work to adapt the code?


devolonter(Posted 2012) [#9]
Hi!

Code written in flixel will not work 'as-is' in the Monkey. There are two reasons for this:

1. The port is not yet complete and not all features from the original flixel are available in Flixel for Monkey.
2. When porting, I used Monkey naming conventions. Due to this the naming of functions is slightly different. For example, in the original we have flixel FlxG.play while in the port you should use FlxG.Play

For greater understanding of differences, I recommend you take a look at the source code of the game Mode on flixel and Flixel for Monkey.


richicon(Posted 2012) [#10]
Thanks devolonter.

I compared the two and it doesn't look too bad, although Mode is a complex project.

I'm guessing smaller examples should be relatively quick to make Monkey friendly.


richicon(Posted 2012) [#11]
Also - to confirm, so far it is just the following functions that aren't ported?

- FlxSave currently is not ported
- Debugger


devolonter(Posted 2012) [#12]
@richicon If you’ve downloaded version with bananas, you can find a few simple examples there (in bananas folder).

FlxSave will be ported in a couple of weeks, and tool for preloaders also will be ready soon.

The following functional was not ported as well: FlxWindow, Debugger, and all functions that use read/write image, because Monkey currently does not support this type of functions.


richicon(Posted 2012) [#13]
@devolonter Cool - thanks for the extra info, that is a big help.

I downloaded the bananas - there are some really useful examples there.

I'm starting off with Monkey Flixel tomorrow - I think first thing will be to get a DAME tilemap in and working.


devolonter(Posted 2012) [#14]
@richicon A little hint. I would recommend you to download the nightly build, as it contains a number of significant changes (such as reflection support), and it will help you when you upgrade to the new version.

You can download bananas for nightly build here


richicon(Posted 2012) [#15]
Got the nightly build and bananas - for some reason when I try to compile and run (HTML5) all examples crash. This was a common error:

Monkey runtime error:Null object access

The "Lastest stable version with bananas" runs all examples fine, but I couldn't get any of the above nightly build bananas to compile with the nightly build code.

I have the latest version of Monkey.


devolonter(Posted 2012) [#16]
Strange. Have just tried it, I do not have this error. Could you build with the "Debug" option to learn more about the error. Does anyone else have such problems?

Also try to remove .build folder


richicon(Posted 2012) [#17]
I reverted back to the Stable build as that works without issue.

I have spent the last couple of days converting this example over to Monkey Flixel - http://www.photonstorm.com/archives/2264/flash-game-dev-tip-13-building-a-retro-platform-game-in-flixel-part-2

I think I am close, it is done and compiles and runs, but somewhere along the line I have gone wrong as it is only drawing the score!

Would you be able to take a look and offer some pointers if I send you the source?


richicon(Posted 2012) [#18]
Here is the link for the source (in a ZIP archive):

http://www.icongames.com/wp-content/files/Pixel.zip


devolonter(Posted 2012) [#19]
I looked through you code. Unfortunately, there are too many mistakes. And some of them do not even relate to the port. For example:

[monkeycode]
For Local ty:Int = 0 Until ty < starMap.heightInTiles
Next
ty=ty+1

For Local tx:Int = 0 Until tx < starMap.widthInTiles
Next
tx=tx+1
[/monkeycode]
This is an incorrect loops entry. It should be the following:

[monkeycode]
For Local ty:Int = 0 Until ty < starMap.heightInTiles
For Local tx:Int = 0 Until tx < starMap.widthInTiles
If(starMap.GetTile(tx, ty) = 1) Then
stars.Add(New Star(tx, ty))
End If
Next
Next
[/monkeycode]
These are the basics of Monkey language and I recommend you to review the Monkey documentation, before moving on to the framework.

Ok, lets go back to the port.

Monkey is a case sensitive language. It means that loadMap and LoadMap is not the same.

If you declare a Global ClassObject: FlxClass = New Level1Class () you must define Level1Class class.

Why do you use Update instead of New?

[monkeycode]
Method Star:Void(X:Int, Y:Int)
LoadGraphic(Assets.STARPNG, True)
Super.Update(X * 16, Y * 16, starPNG)
solid = True
End Method
[/monkeycode]
It should be :

[monkeycode]
Method New(x:Int, y:Int)
Super.New(x * 16, y * 16, Assets.STARPNG)
Solid = True
End Method
[/monkeycode]
Use the resources correctly. If you add a csv file, use AddString, not AddImage. You can find this usage example in bananas.

By default, Monkey does not include csv files to the build. To change that you must add option #TEXT_FILES="*.txt|*.xml|*.json|*.csv" to the beginning of the program. Learn more about App config settings.

A little advice. You will see all the mistakes, if you add reflection module to application. For example, as it goes here:

[monkeycode]
Import flixel
Import src.flxpixel

Import reflection

#REFLECTION_FILTER="src*"
#TEXT_FILES="*.txt|*.xml|*.json|*.csv"

Function Main()
New FlxPixel()
End Function
[/monkeycode]
Alas, nothing more I can do here, because it detracts me from the work on the framework.

Good luck!


richicon(Posted 2012) [#20]
Thanks devolonter. Yes - I think I jumped in a bit early trying to convert this. I've stripped it down and am converting bit by bit, while brushing up on my Monkey code.

Thanks for the tips above, that will be a huge help.


devolonter(Posted 2012) [#21]
Coming soon...




SlopeOak(Posted 2012) [#22]
Hey devolonter; thanks for your work on all of this, btw! Can't wait to use it.

But unfortunately it's not working for me. I'm getting a "reflection module not found!" error when I try to run any of the bananas. I'm running the latest Monkey and the latest Monkey-Flixel and the latest of your bananas. All of them seem to give me this error, but the other bananas included with Monkey do not.

Any ideas?


devolonter(Posted 2012) [#23]
Hi,

Do you have reflection folder in Monkey modules folder?


Neuro(Posted 2012) [#24]
For anyone interested, i did a little tilemap platformer test using Monkey Fixel here. Flixel is actually pretty cool :). I think i shall start using Monkey Flixel more now :).


richicon(Posted 2012) [#25]
Is Monkey Flixel compatible with the Playstation target?


devolonter(Posted 2012) [#26]
For anyone interested, i did a little tilemap platformer test using Monkey Fixel here. Flixel is actually pretty cool :). I think i shall start using Monkey Flixel more now :)

I'm glad to hear it :) You are welcome! Nice demo. Can you send me on email its source? I'll be glad to add this sample to the bananas. Thank you!

Is Monkey Flixel compatible with the Playstation target?

No, unfortunately PSS target currently is not supported.


Neuro(Posted 2012) [#27]
I'm glad to hear it :) You are welcome! Nice demo. Can you send me on email its source? I'll be glad to add this sample to the bananas. Thank you!

Sure thing. I'll clean up the code a bit and send you the source tomrrow.


SlopeOak(Posted 2012) [#28]
devolonter: I do have the reflection folder in the Monkey modules folder... it's a fresh install of Monkey60 and of Flixel for Monkey. It was working under Monkey59. I'm on a Mac and just upgraded to OSX 10.8, too, so not sure if that could be related.

If you have any ideas, please let me know. Meanwhile, I'll keep investigating and will let you know if I find the cause.


devolonter(Posted 2012) [#29]
Sure thing. I'll clean up the code a bit and send you the source tomrrow.

Will be waiting for your email. Thank you again!

devolonter: I do have the reflection folder in the Monkey modules folder... it's a fresh install of Monkey60 and of Flixel for Monkey. It was working under Monkey59.

That is strange. On Windows I get the same error when I delete reflection folder. OK, I will try to reproduce your issue. If I find any solution I'll let you know.


devolonter(Posted 2012) [#30]
@SlopeOak I have just tried to build on Mac with OS X 10.7.2. Unfortunately, I didn't get the same error. Could you run the following sample monkey_path/bananas/mak/reflectiontest/reflectiontest.monkey? Do you have the same error?


SlopeOak(Posted 2012) [#31]
Ok, it must be a bug in Monkey60. I can reproduce it with these steps:

Download fresh copy of Monkey60 on my Mac OSX 10.8 machine. Unzip it and run Monk. Execute the following code (from the wiki Reflection page):

Import reflection

Global MyGlobal:=123

Function Main()

'Get GlobalInfo for MyGlobal 
    Local g:=GetGlobal( "MyGlobal" )

'Read and unbox value of MyGlobal
    Local n1:=UnboxInt( g.GetValue() )

'Print it...
    Print "n1="+n1

'Box and write value of MyGlobal
    g.SetValue( BoxInt( n1*2 ) )

'Read, unbox and dump...
    Local n2:=UnboxInt( g.GetValue() )
    Print "n2="+n2
End


Build it for HTML5 and get the following output:

Translating test
/Users/usr/Desktop/test/MonkeyPro60/bin/trans_macos -target=html5 -run /Users/usr/Desktop/test/test.monkey

TRANS monkey compiler V1.36
Parsing...
Semanting...
Monkey Runtime Error : reflection module not found!

{{~~(null)~~}}


When I do this with Monkey59, it runs as expected. I'll report this bug. Not sure if it's for all Macs using Monkey60, or just Mac OSX 10.8.


devolonter(Posted 2012) [#32]
Thank you for report! I think this bug could be reproduced only on Mac OSX 10.8. In Mac OSX 10.7.2 I don't have this error.


Neuro(Posted 2012) [#33]
Will be waiting for your email. Thank you again!

I just sent it!


devolonter(Posted 2012) [#34]
Nightly build update is available! The main feature of this version is the tweening system that was ported from HaxeFlixel/FlashPunk

List of changes:
* Added tweening system. The following tweenings are supported: Alarm, AngleTween, ColorTween, MultiVarTween, NumTween, VarTween and faders for sound effects. Also tweening system includes the following motion tweenings: CircularMotion, CubicMotion, LinearMotion, LinearPath, QuadMotion and QuadPath

* PSM target support added

* FlxSound.GetValidExt and FlxMusic.GetValidExt functions now return “ogg” for GLFW target

* Method FlxTilemap.Ray bug fixed

* Some minor bug fixes

* Now minimal required Monkey version is V60

Small example of tweening system usage:
[monkeycode]Strict

Import flixel

#REFLECTION_FILTER="flixel*|main*"

Function Main:Int()
New Tween()
Return 0
End Function

Class Tween Extends FlxGame

Method New()
Super.New(640, 480, GetClass("TweenState"), 1, 60, 60)
End Method

End Class

Class TweenState Extends FlxState

Method Create:Void()
Local sprite:FlxSprite = (New FlxSprite(10, 10)).MakeGraphic(100, 100)
Add(sprite)

Local properties:StringMap<Float> = New StringMap<Float>()
properties.Insert("x", FlxG.Width - sprite.width - 10)
properties.Insert("y", FlxG.Height - sprite.height - 10)
properties.Insert("angle", 360)

FlxG.Tween(sprite, properties, 1, FlxTween.TOANDFRO, Null, Ease.SineInOut).Start()
End Method

End Class[/monkeycode]
More information will be soon.


P.S. Now I freeze API changes and go to testing and release preparation. After this v1.0a4 will come out.


Neuro(Posted 2012) [#35]
Is there anyway to show the flixel debugger with Monkey Flixel? I already set forceDebugger=True during the new constructor but it still doesn't show.


devolonter(Posted 2012) [#36]
Hi! Debugger currently is not ported. You can see all elements that were not ported in open issues section.


Neuro(Posted 2012) [#37]
Aww that sucks :). Guess i should of read this thread a little more closely lol. Hope it all gets ported soon then :). BTW, any chance of getting the BMAX target supported also? I tried to do it myself but getting weird errors.


devolonter(Posted 2012) [#38]
Sorry :) Debugger is in my next release TODO list. Also I plan to add BMAX target support, but I don't know when exactly.


Neuro(Posted 2012) [#39]
Hey devolonter, do you have an example of using AddAnimationCallback() with monkey? I can't seem to get that to work at all.


devolonter(Posted 2012) [#40]
Hi!

Callback must implements FlxAnimationListener

Very simple example:
[monkeycode]Class Player Extends FlxSprite Implements FlxAnimationListener

Method New(x:Float, y:Float)
Super.New(x, y)
AddAnimationCallback(Self)
End Method

Method OnAnimationFrame:Void(animName:String, frame:Int, index:Int)
'Your animation handling
End Method

End Class[/monkeycode]


Neuro(Posted 2012) [#41]
Awesome, this works beautifully :). Now looking forward to the rest of the monkey flixel updates :)!


Neuro(Posted 2012) [#42]
Maybe a bug... Directional joysticks works in XNA, but not in GLFW:

[monkeycode] If (FlxG.Keys.Left) or (FlxG.Joystick(0).Pressed(JOY_LEFT)) Then
Facing = FlxObject.LEFT
acceleration.x -= drag.x

ElseIf(FlxG.Keys.Right) or (FlxG.Joystick(0).Pressed(JOY_RIGHT)) Then
Facing = FlxObject.RIGHT
acceleration.x += drag.x
End If[/monkeycode]


devolonter(Posted 2012) [#43]
Hi! Thanks for report. I will deal with it soon and try to fix it.


devolonter(Posted 2012) [#44]
It seems that it is not a bug. Try to run Monkey/bananas/mak/joytest/joytest.monkey and check the results. I got the following (I have very simple joystick):

- it gave no results in XNA (joystick doesn't work);
- joystick works in GLFW, but all buttons shuffled and JOY_LEFT is not a left joystick button and etc. If I specify correct buttons (from joytest.monkey) all statements work fine.


Neuro(Posted 2012) [#45]
Ok i see the issue now. I just tested it this using Xbox360 controller and an older Logitec Rumble Pad 2 controller.

- XNA only works with the 360 Controller and supports all control functions (including the JOY_LEFT, JOY_RIGHT etc) - which is what i mainly test on.

- GLFW only supports JoyX, JoyY, and JoyZ on any controller - JOY_RIGHT, JOY_LEFT etc is not supported so can't use both analogue and control pad at the same time.

Make sense now, so i guess not a bug :). Thanks!


Shanon(Posted 2012) [#46]
Trying to port over a simple flixel example program and got along pretty well, but finally got stumped on this one:

'Called whenever the player touches a coin
Method GetCoin:Void(Coin:FlxSprite, Player:FlxSprite)

Coin.Kill()
score.Text = "SCORE: " + (coins.CountDead() * 100)
if (coins.CountLiving() = 0)

status.Text = "Find the exit."
exitt.exists = true
End
End


Method Update:Void()

'Player movement and controls
player.acceleration.x = 0
if (FlxG.Keys.Left)
player.acceleration.x = -player.maxVelocity.x * 4
elseif(FlxG.Keys.Right)
player.acceleration.x = player.maxVelocity.x * 4
elseif(FlxG.Keys.JustPressed(KEY_SPACE) And player.IsTouching(FlxObject.FLOOR))
player.velocity.y = -player.maxVelocity.y / 2
EndIf

'Updates all the objects appropriately
super.Update()

'Check if player collected a coin or coins this frame
FlxG.overlap(coins, player, GetCoin)




GetCoin is a function that is supposed to be called when the player touches a coin. The example passes the function into the method FlxG.overlap.

The error I'm getting is: Unable to find overload for GetCoin()


Not sure what to put in there to fix this. Any help would be greatly appreciated. Thanks for all the hard work you did on this btw.


devolonter(Posted 2012) [#47]
Hi! Yes, overlap handling in Flixel for Monkey is different from the original flixel. In my port for handling overlap you must implement FlxOverlapNotifyListener. In your case you can do the following:

[monkeycode]Class PlayState Extends FlxState Implements FlxOverlapNotifyListener

'Called whenever the player touches a coin
Method OnOverlapNotify:Void(Coin:FlxObject, Player:FlxObject)

Coin.Kill()
score.Text = "SCORE: " + (coins.CountDead() * 100)
if (coins.CountLiving() = 0)

status.Text = "Find the exit."
exitt.exists = true
End
End

Method Update:Void()

'Player movement and controls
player.acceleration.x = 0
if (FlxG.Keys.Left)
player.acceleration.x = -player.maxVelocity.x * 4
elseif(FlxG.Keys.Right)
player.acceleration.x = player.maxVelocity.x * 4
elseif(FlxG.Keys.JustPressed(KEY_SPACE) And player.IsTouching(FlxObject.FLOOR))
player.velocity.y = -player.maxVelocity.y / 2
EndIf

'Updates all the objects appropriately
super.Update()

'Check if player collected a coin or coins this frame
FlxG.overlap(coins, player, Self)
End Method

End Class[/monkeycode]
Good example is a mode-game


Shanon(Posted 2012) [#48]
Thank you very much. That makes a ton of sense.

Yeah, got my little example to work!

Donation sent.


Neuro(Posted 2012) [#49]
Since the debugger is not working yet, is there anyway to get the FPS to be displayed? I also noticed the folks on the actual Flixel forums have had the same issue.


devolonter(Posted 2012) [#50]
At last! I am happy to announce the release of the new version of Flixel for Monkey (F4M) - v1.0a4. It is the biggest update since the first release.

Little by little I stray from the original flixel, because it wasn't updated for a long time and it does not suffice many things. That’s why, now besides porting the primary functional I track other popular libraries and port something useful to F4M. If you have feature requests, please write about them, I will examine each one.

In this version was included many things that were available earlier in the nightly builds, and this version is nothing more than free from nightly build version bugs. Nevertheless, I'll put here the entire list of changes for those who didn’t track updates.

Important! This version is not compatible with the previous version. Your projects will not work after the upgrade. So please read the list of changes carefully. Adapting the code for the new version should not take much time, but if you are close to the release of your game - better not to upgrade!

The full list of changes:

* Now minimal required Monkey version is V60

* Added resolution policies. These allow you to easily control the behavior of the screen when you change the size of the device. The following resolution policies are available: FillResolutionPolicy (by default), RatioResolutionPolicy, FixedResolutionPolicy and RelativeResolutionPolicy. In order to set the resolution policy, use the FlxG.SetResolutionPolicy:Void(resolutionPolicy:FlxResolutionPolicy)

* Added tweening system. The following tweenings are supported: Alarm, AngleTween, ColorTween, MultiVarTween, NumTween, VarTween and faders for sound effects. Also tweening system includes the following motion tweenings: CircularMotion, CubicMotion, LinearMotion, LinearPath, QuadMotion and QuadPath

* PSM target support added

* Full version now includes plugins from photonstorm

* The constructor of the class FlxGame accepts ClassInfo by the third parameter. For example, New FlxGame (640, 480, GetClass ("HelloWorldState"))

* FlxGroup.SetAll accepts the string field name (properties are also supported) by the first parameter

* FlxGroup.CallAll accepts the string name of the function by the first parameter

* FlxGroup.Sort accepts the string field name by the first parameter

* All globals ClassObject:Object declared inside each class are automatically initialized at the time of creating an instance of the game.

* There is no need to override GetClass method of the FlxState class

* The cursor and sound tray are no longer part of the main camera. Thus the zoom of the camera and its position doesn't act on them. Now they are the part of the screen and only valid screen size and global device scale factor act on them

* FlxSound.GetValidExt and FlxMusic.GetValidExt functions now return “ogg” for GLFW target

* The following interfaces are removed: FlxClass, FlxBasicSetter, FlxBasicInvoker, FlxBasicComparator

* FlxGame.useVirtualResolution field and FlxG.FullScreen function have been removed. Use resolution policies

* Fixed the cursor scale bug

* Fixed work of a few the buttons in several cameras

* Method FlxTilemap.Ray bug fixed

* Fixed auto tiling bug with FlxTilemap.ALT option

* Some minor bug fixes

List of photonstorm plugins included in v1.0a4 version:

* FptFlxColor

* FptFlxMath (partially ported)

* FptFlxVelocity

* FptFlxWeapon (partially ported)

Important! ClassObject must have an Object type and before using should be upcast to ClassInfo. For example, FlxGroup.Recycle (ClassInfo (FlxSound.ClassObject)). You can also use the following approach: FlxGroup.Recycle (GetClass ("FlxSound")), but it may not be very good for performance.

Before the new version use, make sure that you set REFLECTION_FILTER in your main file. Optimal REFLECTION_FILTER is #REFLECTION_FILTER="your_app*|flixel.flx*|flixel.plugin*".

Unfortunately, temporarily I had to abandon porting FlxSave and FlxPreloader, as there are still a lot of work with them and I didn’t manage to port them. FlxSave will be included in the next release, and FlxPreloader probably a little later.

So what's next? I have big plans for F4M, but not all at once. Now I want to take a break until September and work on my games, as well as to take part in Ludum Dare #24. Work on the F4M takes a hell of a lot of time, so now I have almost no energy to continue. I think a break will do me good. In September, I’ll announce my further plans.

Now I would like to thank monkeycoder.co.nz community users, who helped me with development of this version:

* Felipe Alfonso (ilovepixel) - for bug reports and two games

* Gil Villarreal (Gil) - for bug reports and bug fixes

* Rachid Abdul (Neuro) - for platformer example

* Aleksey Kazantsev (KaaPex) - for porting Flixel Powert Tools

Also I want to thank people who are not from "Monkey world" and without whose assistance some features would not have been implemented:

* Alexander Hohlov (Beeblerox) for HaxeFlixel

* Matthew Tuttle (Matt_Tuttle) for HaxePunk

* Chevy Ray Johnston (ChevyRay) for FlashPunk

* Nicolas Gramlich (nicolasgramlich) for AndEngine

Special thanks to people who supported me by making a donation. This is really important to me:

* Artsiom Trubchyk (programmer)

* Arthur Ostapenko (Arthur)

* Shanon Fernald (Shanon)

Thank you!

Sorry for this long post. And thanks for having read up to the end. Now I suggest you go to the download page and to download the latest version of F4M!

Happy coding!

@Neuro currently, you can display/calc fps only with the help of custom counter


Shanon(Posted 2012) [#51]
Congrats!

I'm using monkey 61B (latest) and I'm having an issue with the new release.

I think I was using a nightly version of flixel from a few days ago which was working fine.

So what I did was grab the stable build you just released. I renamed the flixel module I was using to flixel_old and pasted in the new flixel folder.

Now when I compile the project I'm working on, I get this error:

TRANS monkey compiler V1.37
Parsing...
Semanting...
C:/Users/sfernald/Documents/MonkeyPro61b/modules/monkey/stack.monkey<26> : Error : Arrays cannot be compared.
Abnormal program termination. Exit code: -1

Will go back to using the old version for now.

Thanks for the great work and I'll probably use monkey and flixel on ludumdare as well.

I didn't even know about the flixel power tools. Are you going to port that whole thing over hopefully? You got to, it's so cool.

Also, is reflection ever coming and is it even possible with monkey?

Take care,
shanon.


KaaPex(Posted 2012) [#52]
You have to use #REFLECTION_FILTER="you_src*|flixel*" to prevent this Error.


devolonter(Posted 2012) [#53]
Hi, Shanon. Thanks!

It seems that you use another build, but not the nightly one. This error occurred when #REFLECTION_FILTER was not set. The use of Monkey reflection is the main feature of this F4M version.

You can find out about flixel power tools from KaaPex's flixel power tools thread.

I’ve made a small guide about code conversion from previous versions:
[monkeycode]'Simple guide how to convert your code for compatibility with v1.0a4

Import flixel

Import flixel.flxtext.driver.angelfont

'Now your main file MUST begin with #REFLECTION_FILTER
'IMPORTANT! You should replace your_app* by your app filter. I recommend to save your source files in src folder. In this case filter
'will be just #REFLECTION_FILTER="src*|flixel.flx*|flixel.plugin*"
#REFLECTION_FILTER="your_app*|flixel.flx*|flixel.plugin*"

Function Main()
New HelloWorld()
Return 0
End Function

Class HelloWorld Extends FlxGame

Method New()
'Earlier you had to use state's ClassObject
'
'Super.New(640, 480, HelloWorldState.ClassObject)

'Now it is just state's ClassInfo.
Super.New(640, 480, GetClass("HelloWorldState"))
End Method

Method OnContentInit:Void()
'Earlier you had to use the following code for init another text driver
'
'FlxTextAngelFontDriver.Init()
'FlxText.SetDefaultDriver(AngelfontTextDriver)

'Now you should use the following
FlxTextAngelFontDriver.Init()
FlxText.SetDefaultDriver(ClassInfo(FlxTextAngelFontDriver.ClassObject))

'Or

FlxText.SetDefaultDriver(GetClass("FlxTextAngelFontDriver"))

'A little bit ugly, but I'll improve this in next release
End Method

End Class

Class HelloWorldState Extends FlxState

'Now the use ClassObject is not required
'
'Global ClassObject:FlxClass = new HelloWorldStateClass()

'If you want to use ClassObject in your app, you just need to declare it as an Object.
'Flixel for Monkey automatically initializes this variable when app will be started
'Before using this variable you must upcast it to ClassInfo. For example, FlxGroup.Recycle(ClassInfo(FlxSound.ClassObject))
Global ClassObject:Object

Method Create:Void()
Local helloWorld:FlxText = New FlxText(10, 10, 620, "Hello World!")
helloWorld.SetFormat(FlxText.SYSTEM_FONT, 16, FlxG.WHITE, FlxText.ALIGN_CENTER)
Add(helloWorld)
End Method

'Now there is no need to override GetClass method of the FlxState class
'
'Method GetClass:FlxCalss()
' Return ClassObject
'End Method

End Class

#Rem

Ugly FlxClass now has been removed. Just remove it from your code

Class HelloWorldStateClass Implements FlxClass

'Creates new instance of an object
Method CreateInstance:Object()
Return New HelloWorldState()
End Method

'checks that the scanned object belongs to a class
Method InstanceOf:Bool(object:Object)
Return (HelloWorldState(object) <> Null)
End Method

End Class
#End

'You can find more in updated bananas[/monkeycode]
Frequently occurred errors:

- stack.monkey<26> : Error : Arrays cannot be compared
#REFLECTION_FILTER wasn’t set. More here

- Cannot call method ‘m_NewInstance’ of null
#REFLECTION_FILTER is not valid

- Resource beep_flx can’t be loaded in GLFW
SOUND_FILES and MUSIC_FILES settings in CONFIG.txt are not valid. More here


Neuro(Posted 2012) [#54]
Thanks for all the great work devolonter! I took a look at the new updates and should be pretty easy to implement in my current project :).

If you have feature requests, please write about them, I will examine each one.

Everything is going great so far i would suggests :
- Continue on debugger, and preloader.
- Definitely continue on powertools plugins (this is actually directed at KaaPex)
- (big one) BlitzMax target functionality!!!


devolonter(Posted 2012) [#55]
Hi, Neuro. Let me know if you have any troubles with implementation. I'll try to help.

Thanks for requests! I plan to implement all of them.


Shanon(Posted 2012) [#56]
Piece of cake. Thanks very much for the clear document. Things work great again.

Wow, things are really changing. You took care of most of the annoying, ugly stuff I was noticing as I was porting my game over.


Neuro(Posted 2012) [#57]
Edit : nevermind....wow i'm having a bad night lol...


devolonter(Posted 2012) [#58]
Today port Flixel for Monkey celebrates its first serious date - one year after the first commit. Unfortunately, at the moment, I can not devote a lot of time to framework development, but I also do not want it was without updates all this time. Therefore, I’ve prepared a little plan that I want to improve and develop in F4M in the near future.

So, I plan to:

* Add MonkeyMax target support. I'm not sure it would work, but I'll add all the necessary for this platform support

* Add texture atlases support, with the ability to write your own loaders. By default, will be available loader for atlases which were created in TexturePacker

* Add support for choosing the update strategy. By default, your state update is in the method OnRender (for smoother objects movement), which in some cases leads to undesirable consequences. With the help of FlxGame.SetUpdateStrategy method we can put state update to the OnUpdate method.

* Add GetChar method support in Keyboard class

* Add auto-detection of X and Y padding in images, to load images with correct flags

* Improve rendering algorithm of tile map when using the zoom

* Replace private method _DrawSurface with callback function OnRender, to simplify overriding of objects rendering

* Rename FlxBasic.GetClass method to FlxBasic.GetClassInfo, to avoid conflicts with the GetClass function of reflection module

* Bug fixes

* Look through pull-requests to the original Flixel and, where necessary to bring them to the port

I plan to release this small update to the end of November, but I’m not sure about it for 100%. Watch for updates in the repository.

P.S. I’ve decided to refuse from the nightly builds, as they take a lot of time time and very few people use them. For those who wants to keep up on changes I suggest to follow the project’s dev-branch.


Neuro(Posted 2012) [#59]
This is great news, thanks for the update!


devolonter(Posted 2012) [#60]
OK. After all bug fixes in MonkeyMax I'm glad to inform that Flixel For Monkey works fine with BlitzMax target. See dev version.

Cheers! :)


devolonter(Posted 2013) [#61]
Recently, I was often asked about errors in V68. Unfortunately, I had no time to prepare an update to the new Monkey version release. So, in order to use framework with Monkey V68 temporary use V67 branch. It fixes all the conflicts, as well as adding support for Win8 and WP8 targets. More news and official update next week.


Isrex(Posted 2013) [#62]
Oh, this is really great. I just started using Flixel and I love it. Nice to see it is still alive!


devolonter(Posted 2013) [#63]
Update is available! The new version does not add anything new, and only fixes compatibility issues with the new Monkey version

This is the last alpha version of the project. Now I will concentrate on finishing the port and its promotion from alpha state to more stable version. I do not know how long it will take me, and how soon I can start. Nevertheless, I'll try to keep you informed. I'm glad to hear that users continue to use my port, although for a long time there were no updates. I apologize for that and I hope I manage to solve this issue.


Neuro(Posted 2013) [#64]
Thanks for the update!


Raz(Posted 2013) [#65]
Going to have to give this another look now I'm not focusing on an Xbox release :) Thanks for going to the effort of making it.

Are you able to describe what you mean by "resolution policies" ?


devolonter(Posted 2013) [#66]
Term and resolution policies behavior were borrowed from the AndEngine. Resolution policy is responsible for how the game will be displayed, if the resolution is higher or less than the set.

By default flixel has several standard resolution policies (fill, fixed, ratio and relative). But you can define yours by just implementing the interface FlxResolutionPolicy.

Demonstration of how it works:
http://lab.devolonter.ru/libs/monkey-flixel/resolutionpolicy/html5.html

Source: https://github.com/devolonter/flixel-monkey-bananas/blob/master/resolutionpolicy/src/playstate.monkey


Raz(Posted 2013) [#67]
Ahh I see, that's fantastic :)


Isrex(Posted 2013) [#68]
Does it work with the latest version of monkey (v69)??


Raz(Posted 2013) [#69]
It does, yes


Raz(Posted 2013) [#70]
Edit: Sorry, I think I've actually got it working now, I wasn't setting the actual camera view size (stupid me). It works when using

Local zoomCam:FlxZoomCamera = New FlxZoomCamera(0,0,100,100);
zoomCam.SetBounds(0, 0, level.width, level.height);
zoomCam.targetZoom = 2.0
zoomCam.Follow(player,FlxCamera.STYLE_PLATFORMER)
		
FlxG.ResetCameras(zoomCam)



Original:devolonter: cheeky request, but do you think you could implement ZoomCamera ( http://bullettimeninja.blogspot.co.uk/2011/09/zoom-camera.html )?
I've tried doing it myself but I'm really not having too much luck!

Here's what I was adding to flxcamera.monkey

[monkeycode]' ZoomCamera: A FlxCamera that centers its zoom on the target that it follows
' Flixel version: 2.5
'
' @link http://www.kwarp.com
' @author greglieberman
' @email greg@...
''

Class FlxZoomCamera Extends FlxCamera


''
' Tell the camera to LERP here eventually
''
Field targetZoom:Float

''
' This number is pretty arbitrary, make sure it's greater than zero!
''
Field zoomSpeed:Float = 25

''
' Determines how far to "look ahead" when the target is near the edge of the camera's bounds
' 0 = no effect, 1 = huge effect
''
Field zoomMargin:Float = 0.25


Method New(x:Int, y:Int, width:Int, height:Int, zoom:Float=0)

Super.New(x,y,width,height,zoom)

targetZoom = 1

End

Method Update:Void()

Super.Update()

' update camera zoom
Zoom += (targetZoom - Zoom) / 2 * (FlxG.Elapsed) * zoomSpeed

' if we are zooming in, align the camera (x, y)
If(target And _zoom <> 1)
alignCamera()
Elseif
X = 0
Y = 0
Endif
End


''
' Align the camera x and y to center on the target
' that it's following when zoomed in
'
' This took many guesses!
''
Method alignCamera:Void()


' target position in screen space
Local targetScreenX:Float = target.x - scroll.x
Local targetScreenY:Float = target.y - scroll.y

' center on the target, until the camera bumps up to its bounds
' then gradually favor the edge of the screen based on zoomMargin
Local ratioMinX:Float = (targetScreenX / (Width/2) ) - 1 - zoomMargin
Local ratioMinY:Float = (targetScreenY / (Height/2)) - 1 - zoomMargin
Local ratioMaxX:Float = ((-Width + targetScreenX) / (Width/2) ) + 1 + zoomMargin
Local ratioMaxY:Float = ((-Height + targetScreenY) / (Height/2)) + 1 + zoomMargin

' offsets are numbers between [-1, 1]
Local offsetX:Float = Clamp(ratioMinX, -1.0, 0.0) + Clamp(ratioMaxX, 0.0, 1.0)
Local offsetY:Float = Clamp(ratioMinY, -1.0, 0.0) + Clamp(ratioMaxY, 0.0, 1.0)

' offset the screen in any direction, based on zoom level
' Example: a zoom of 2 offsets it half the screen at most
X = -(Width / 2) * (offsetX) * (_zoom - 1)
Y = -(Height / 2) * (offsetY) * (_zoom - 1)

End

End[/monkeycode]

And here's what I was hoping to add to the playstate create function

Local zoomCam:FlxZoomCamera = New FlxZoomCamera();
		FlxG.ResetCameras( zoomCam );
		zoomCam.targetZoom = 2;



devolonter(Posted 2013) [#71]
Raz, yes, I think the author of the post made a mistake when wrote new ZoomCamera(). Interesting post, I’ll think how we can use it. Thank you!

BTW, development version is now also compatible with Monkey V69. You can see the changes here - https://github.com/devolonter/flixel-monkey/blob/develop/CHANGELOG.md


Isrex(Posted 2013) [#72]
Hi guys, noob question.

How can I detect touch input with Flixel? Im making a game and trying to make it work on my android device. I want to be able to touch an image that will move the main character right for an example.

Should I use mouse input detection?? How can I detect a click over the image??

Thanks!


devolonter(Posted 2013) [#73]
Hi. Very basic example
Class PlayState Extends FlxState

	Field left:FlxSprite
	
	Field right:FlxSprite
	
	Field touchPos:FlxPoint
	
	Method Create:Void()
		left = New FlxSprite(20, FlxG.Height - 50)
		Add(left)
		
		right = New FlxSprite(FlxG.Width - left.width - 20, FlxG.Height - 50)
		Add(right)
		
		touchPos = New FlxPoint()
	End Method
	
	Method Update:Void()
		If FlxG.Touch().Pressed() Then
			FlxG.Touch().GetScreenPosition(FlxG.Camera, touchPos)
		
			If left.OverlapsPoint(touchPos, True) Then
				FlxG.Log("move left")
			
			ElseIf right.OverlapsPoint(touchPos, True) Then
				FlxG.Log("move right")
			
			End If
			
		End If
	End Method

End Class



Isrex(Posted 2013) [#74]
Awesome!!! Even I can do that :)

Thank you!!

Edit: Where can I find the methods for FlxG.Touch()??


devolonter(Posted 2013) [#75]
For the time being, you can find it only in the source code:

https://github.com/devolonter/flixel-monkey/blob/master/system/input/xydevice.monkey
https://github.com/devolonter/flixel-monkey/blob/master/system/input/touch.monkey

Also, you can find some examples in this repo: https://github.com/devolonter/flixel-monkey-bananas

I hope, I can find some time to write docs


Isrex(Posted 2013) [#76]
Ok here I go with a TOTAL NOOB question. I'm really embarrased about asking this, but I will be worse if I just don't ask as I really want to know.

I have a Player class which takes care of creating a player, moving it around and making him shoot bullets.

In it, I just created a Method for my player to shoot, but I want to call that method from outside the class, let's say I want to call it from the playstate class in the update method when the user uses his finger to touch the shoot button (duh).

But I don't know how to access that "custom" shoot method inside my Player class.

Method Shoot:Void()
   GetMidpoint(_heplerPoint)
 Bullet(_bullets.Recycle(ClassInfo(Bullet.ClassObject))).Shoot(_heplerPoint, _aim)
End


That's based from the "Mode" Game.

And from my playstate class in the update methos I'm trying to do something like this:

If (FlxG.Touch().JustPressed())
   _player.Shoot()
EndIf



Neuro(Posted 2013) [#77]
I generally do all the player controls in the player class itself. However, if you really want to call that method from the PlayState class, you can try something like this in the Update method :
Player(_player).Shoot();



Isrex(Posted 2013) [#78]
I'm doing it in the PlayState class because I don't know how to detect touch input from the Player class over the button sprites that I added in the PlayState class.

Thanks Neuro!


FelipeA(Posted 2013) [#79]
Hello devolonter, I wanted to ask you if there is a way to make a preloader on flixel monkey? I have a lot of big images loading and it's taking a while to show just the menu ( it's a html5 webapp for iOS ). I am thinking this just to show the player something and not stare at a black screen.

Thanks!


devolonter(Posted 2013) [#80]
ilovepixel, not sure that it helps you with HTML5 target. But this code I used for mobile platforms. This is a quick copy from the working draft, so there may be some errors:



The big issue of HTML5 target is a big main.js file. That also takes time to load. As a simple solution, you can set the background for the canvas via CSS. It will be displayed until the game starts.


FelipeA(Posted 2013) [#81]
Thanks a lot devolonter, this will help a lot. I've added a webapp module to flixel so i'll be using this a lot!

I have a new question. How do I handle the button down event on FlxButton?

Thanks!

#Edit: Nvm, already found a way to do the down button thing :)

#Edit 2: Does FlxButton support multi-touch? I am doing a small game for android and I can't press 2 buttons at the same time.


devolonter(Posted 2013) [#82]
Yes, FlxButton works only with a mouse and one-touch. I think it's wrong ...
I’ve made a FlxButtonEx class for you, which supports multi-touch:



But I will add multi-touch support for FlxButton to my to-do list


FelipeA(Posted 2013) [#83]
You are awesome!

Thanks a lot for this, it worked really good.


devolonter(Posted 2013) [#84]
Nice! I was glad to help :)


Neuro(Posted 2013) [#85]
Something weird with the latest update. The FlxG.Keys.JustPressed() or KeyHit() commands doesn't work in HTML5 anymore.


devolonter(Posted 2013) [#86]
Neuro, thanks for the report! I think the issue is connected with the fact that the logic update takes place in OnRender. I refused from it in the new version, so I think the issue is not in the develop version. But I'll check it out.

I finally have enough time to get back to work on the port, so I think in the next 2-3 weeks I will promote it from develop to stable version. Many changes are planned and some of them have already been implemented. It will be a really big update.


Neuro(Posted 2013) [#87]
Awesome news, looking forward to it :)!


Appy Media(Posted 2013) [#88]
Hi Devolonter,

Just wanted to say thanks for all your hard work. Awesome port!

For me I'm just discovering Monkey and your Flixel port really helps. By porting an already mature engine with plenty of AS3 examples that are fairly easy to convert / understand is a massive boon.

I'm wondering how your getting on with the mentioned 'big update', any ideas on when you might be releasing and what might be coming?

p.s. I put a little donation your way which I hope is ok. If I can keep on using what you have I'll be sure to keep on donating, thanks again.

Pete


devolonter(Posted 2013) [#89]
Hi,

'Big update' will be available very soon. I don’t want to name any specific dates, but only 8 small issues remained to resolve to release it.

The main changes that will appear in the new version:
- The system of slots/signals
- Substates
- Enable/disable WebGL by using the config setting
- Configure the input by using the config setting
- Target independent code for the base support of future custom targets
- Support of MonkeyMax and OUYA targets
- Ability to override render sprites

And a lot of other changes, improvements and bug fixes about which I will write after the release.

Thank you very much for your donation and your gratitude. This is really important for me! I hope that you will enjoy the work with the port.


Appy Media(Posted 2013) [#90]
Hi,

The update sounds great, very much forward to it all :)


Neuro(Posted 2013) [#91]
Wow, hows this coming along now?


devolonter(Posted 2013) [#92]
You can try develop branch right now. At the moment I use it in a commercial project and it works pretty stable. It does have some breaking changes though... I'll provide update before Ludum Dare 27 (August 23rd) or perhaps earlier, depending on my spare time. Currently I have real issues with finding time for it.


FelipeA(Posted 2013) [#93]
Hello,
Is there any example of how to use on flxtext multiple fonts made with fontmachine?

I have a game with 3 different fonts I've been able to load the first one with this:



I don't know how to handle multiple fonts with flixel and fontmachine.

Thanks!


#EDIT

I finally solved this. I Don't know if is the correct way, but it work:



Then when I want to use that font I put:



thanks :)


devolonter(Posted 2013) [#94]
Sorry for late reply. Your solution is absolutely correct! :)


devolonter(Posted 2013) [#95]
New version v1.0.0-beta.1 is out! Be careful, this version has a lot of breaking backward compatibility changes and may be less stable than the previous alpha. Unfortunately, I didn't have time to prepare the examples, but all old examples upgraded to the new version.

You can read a detailed list of changes in devblog
You can download new version from the new official site: flixelmonkey.com


devolonter(Posted 2013) [#96]
Important update! Alpha versions of Flixel for Monkey have issues with latest Chrome version. You can find more info and fixing instructions in devblog post: http://blog.flixelmonkey.com/post/60951156858/fix-for-keyboard-issue-with-latest-version-of-chrome

Also, here is a short video that demonstrates Flixel app running on OUYA target:



computercoder(Posted 2013) [#97]
That is very cool! Good work devolonter :)


Neuro(Posted 2013) [#98]
This is frickin awesome. I need to get back to coding soon :(....


FelipeA(Posted 2013) [#99]
To the OUYA video I also want to add the PS Vita video:



Thanks a lot devolonter!


devolonter(Posted 2013) [#100]
@ilovepixel nice to see it! Thanks!


Neuro(Posted 2013) [#101]
Visual.debug no longer working on the latest version?


devolonter(Posted 2013) [#102]
Visual debug works only in debug mode by default. If you want to force enable debug in release mode you should enable flixel debug with #FLX_DEBUG_ENABLED = True


Neuro(Posted 2013) [#103]
Ahh thanks, got it now.


FelipeA(Posted 2014) [#104]
Hey devolonter,

I downloaded the latest version of Flixel and it gave me this error, even with the banana examples.

/flixel/flxconfig.monkey<46> : Error : Cannot convert from Bool to String. 



Neuro(Posted 2014) [#105]
Yep needs an update. Also much more errors with v77d. Devolonter a probably a bit busy with the site redesign now so not sure when he'll get to updating it.


devolonter(Posted 2014) [#106]
Hi guys!

Thanks for the reports, I known about these issues. I’ll provide some news about that next week. But currently, you can try to use version from develop branch, it should work properly.


Whiteball(Posted 2014) [#107]
Thanks for all the great work on Flixel for Monkey. I'm currently using it on my project and its been great to use and speeded up my dev time no end.

I'm currently trying to use the slots and signals stuff but not having much luck. Can anyone help out with a code example (simpler the better, I'm not that good yet).


Whiteball(Posted 2014) [#108]
Having trouble now with scaling tilemaps and lines between the tiles. Might have to give up on this as I can't seem to find a fix.


devolonter(Posted 2014) [#109]
Hi, Whiteball.

Sorry, I missed your first message… I hope you solved the issue with slots and signals.

Regarding the lines between tiles. It may occur when your tiles’ sprite didn’t have padding between frames. In your case you can try one option from the following:

1. Set #MOJO_IMAGE_FILTERING_ENABLED=False
2. Set Image.DefaultFlags = Image.XYPadding before loading resources
3. Add 1px transparent padding to each frame of your tiles strip and set Image.DefaultFlags = Image.XYPadding before loading resources


Richard Marks(Posted 2014) [#110]
I downloaded Monkey X v77a and Flixel for Monkey v1.0.0-beta.1 and apparently they do not play well together.

Is there any way to get things up and running short of running through all of the flixel code and fixing each error as they pop up when I try to build my project?