Code Monkey home page Code Monkey logo

haxepunk's Introduction

Build Status Code Climate MIT License Haxelib Join the chat at https://gitter.im/HaxePunk/HaxePunk

HaxePunk

HaxePunk is a powerful cross-platform 2D game engine, based on the FlashPunk AS3 library.

  • Builds for HTML5 (WebGL), Windows, Mac, Linux, iOS, and Android
  • Hardware acceleration and texture atlas support
  • Gamepad and multi-touch input

Release build

First, make sure you have Haxe 3.0 or higher, we recommend you to update to Haxe 3.2 if you haven't already. Then execute the following commands below to get started with your first HaxePunk project. If you are using Haxe 2 the last version supporting it was v2.3.0 haxelib install HaxePunk 2.3.0.

haxelib install HaxePunk
haxelib run HaxePunk setup
haxelib run HaxePunk new MyProject # creates a new project

Development build

You will need a C++ compiler for native builds (Xcode, Visual Studio, g++).

git clone https://github.com/HaxePunk/HaxePunk.git
make

This will build documentation, run unit tests, and run the example project. If you fix an issue, feel free to create a pull request.

If you've cloned locally, you can set your local repo as a development directory accessible through Haxelib:

git clone https://github.com/HaxePunk/HaxePunk.git
haxelib dev HaxePunk HaxePunk/

To disable the dev directory for HaxePunk simply run the command haxelib dev HaxePunk. Notice there is no third argument passed.

If you just want to install the latest dev version from Git, you can also do this with haxelib:

haxelib git HaxePunk https://github.com/HaxePunk/HaxePunk.git dev

Have questions or looking to get involved?

There are a few ways you can get involved with HaxePunk.

  • The development roadmap is available on Trello.
  • Come chat with us on Discord or Gitter.
  • Drop by the HaxePunk forum to ask a question or show off what you've created.
  • Create an issue or pull request or take part in the discussion.
  • Follow us on Twitter: @HaxePunk

Credits

  • Chevy Ray Johnston for creating the original FlashPunk.
  • OpenFL makes native targets possible and simplifies asset management. Thanks guys!
  • All the awesome people who have contributed to HaxePunk and joined in the discussions on the forum.

MIT License

Copyright (C) 2012-2017 HaxePunk contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

haxepunk's People

Contributors

abeltoy avatar advetter avatar andyli avatar anheurystics avatar azrafe7 avatar banach-tarski avatar beeblerox avatar bendmorris avatar djpale avatar edgarmagdaleno avatar elnabo avatar fserb avatar gama11 avatar ikonone avatar jacic avatar jfroco avatar julsam avatar lived123456 avatar malhcat avatar marc010 avatar marwes avatar matrefeytontias avatar matttuttle avatar nananas avatar raistlin avatar scriptorum avatar squiddingme avatar webninjasi avatar wselken avatar xanozoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

haxepunk's Issues

Tween Infinite Loop.

The function removeTween in Tweener has:

if (ft._prev != null)
{
    ft._prev._next = ft._next;
}
else
{
    if (ft._next != null)  //  Here is the issue?
        _tween = cast(ft._next, Tween);
}

That null check means that _tween will not be null when there is not a next tween.

If you look at addTween, it does:

ft._next = _tween;

So, the infinite loop occurs if you have one tween added, removed, then added a second time.

var testTween:Tween = new Tween(blah);

//  ft._next == null since _tween == null  AND _tween is later set to reference the test tween.
addTween(testTween);

// ft._prev != null evaluates to false
// else
// ft._next != null evaluates to false
// _tween is never set to null so the tween continues to update after being removed
removeTween(testTween);

// ft._next == _tween == testTween.  Infinite Loop during updateTweens.
addTween(testTween);

Hopefully that made sense. I would submit a fix but I have a development version of haxe right now...

Possible solutions:

  1. Simply remove the null check.
  2. If cast throws an error:
_tween = ft._next == null ? null : cast(ft._next, Tween);

JoystickEvent causes compile error for Flash target

Hi Matt,

NME 3.3.2 handles the mapping of classes a little bit differently. Since Flash and HTML5 do not support joysticks right now, the JoystickEvent class is not available.

Do you think that we should be handling this with a silent failure, so you can compile applications but receive no joystick input, or do you think it should be more strictly enforced, where it throws a compile error if you try to use a joystick while targeting a platform that does not support it?

If you think this should be a silent failure, we can probably update NME to handle it that way (as it was before). Otherwise, would you mind updated your code so it includes joystick support "#if (nme && (cpp || neko))" instead of "#if nme" (or something like that)?

Thanks!

Bug when the screen is scaled up and resized

Hi,

Found a bug when you change the scale of the screen, say HXP.screen.scale = 2;, then, if you resize the flash window, a error is thrown :

ArgumentError: Error #2015: Invalid BitmapData.
    at flash.display::BitmapData/ctor()
    at flash.display::BitmapData()
    at com.haxepunk::HXP$/createBitmap()[C:\Users\bender\dev\nme\HaxePunk102\src\com\haxepunk\HXP.hx:810]
    at com.haxepunk::Screen/resize()[C:\Users\bender\dev\nme\HaxePunk102\src\com\haxepunk\Screen.hx:65]
    at com.haxepunk::HXP$/resize()[C:\Users\bender\dev\nme\HaxePunk102\src\com\haxepunk\HXP.hx:210]
    at com.haxepunk::Engine/resize()[C:\Users\bender\dev\nme\HaxePunk102\src\com\haxepunk\Engine.hx:220]
    at MethodInfo-209()[C:\Users\bender\dev\nme\HaxePunk102\src\com\haxepunk\Engine.hx:186]

Found out it tries to create a BitmapData with negative size. I think it's because of this 2 lines in HXP.resize() :

width = Std.int(width / HXP.screen.fullScaleX);
height = Std.int(height / HXP.screen.fullScaleY);

HXP.tween() options null check doesn't work with NME targeting CPP

For some reason the null check if (options) doesn't work. Once you replace it with if (options != null) everything works. Everything worked fine targeting flash, it wasn't until I tested the windows target that I got this issue.

HXP.hx line:854 is

if (options)

The line should be

if (options != null)

Specifically I was seeing the on complete function not get registered and with this change it's properly registered.

Tween.hx is missing cancel() found in FP's Tween.as

It's a straight port, not sure why it's missing. Here it is:

/**
 * Immediately stops the Tween and removes it from its Tweener without calling the complete callback.
 */
public function cancel()
{
    active = false;
    if (_parent != null)
    {
        _parent.removeTween(this);
    }
}

Crash while debugging under neko.

While working thru the tutorial (103) and having just added the ship, I added -debug while running under Neko. I clicked on the green box in the upper left & I got a crash with the following stack trace. Doing the same thing under Flash causes no problems.

Called from sys.io.FileOutput::$statics line 1
Called from ApplicationMain::main line 39
Called from nme.Lib::create line 77
Called from native.Lib::create line 73
Called from native.display.Stage::nmeProcessStageEvent line 382
Called from native.display.Stage::nmeDoProcessStageEvent line 292
Called from native.display.Stage::nmePollTimers line 718
Called from native.display.Stage::nmeCheckRender line 247
Called from native.display.Stage::nmeRender line 731
Called from native.display.DisplayObjectContainer::nmeBroadcast line 141
Called from native.display.DisplayObjectContainer::nmeBroadcast line 141
Called from native.display.DisplayObjectContainer::nmeBroadcast line 156
Called from native.display.DisplayObject::nmeBroadcast line 165
Called from native.display.DisplayObject::nmeDispatchEvent line 179
Called from native.events.EventDispatcher::dispatchEvent line 80
Called from native.events.Listener::dispatchEvent line 201
Called from com.haxepunk.Engine::onEnterFrame line 250
Called from com.haxepunk.debug.Console::update line 448
Called from com.haxepunk.debug.Console::updateDebugRead line 927
Uncaught exception - Invalid field access : toString

In Neko build, HXP.random returns negative values

When running under Neko, HXP.random should return values from 0 to 1, but sometimes returns negative values:

    HXP.randomSeed = 0x20000000;        
    trace(HXP.random); // returns -0.249998043873346

This seems to occur when using Std.int() to convert the float value back to int. I don't think that this is necessarily a great solution, but adding 1 if it goes negative brings the value back into range.

    /**
     * A pseudo-random Float produced using FP's random seed, where 0 <= Float < 1.
     */
    public static var random(getRandom, null):Float;
    private static inline function getRandom():Float
    {
            _seed = Std.int((_seed * 16807.0) % 2147483647.0);
            var result = _seed / 2147483647.0;
            return (result < 0 ? 1 + result : result);
    }

    /**
     * Returns a pseudo-random Int.
     * @param       amount          The returned Int will always be 0 <= Int < amount.
     * @return      The Int.
     */
    public static inline function rand(amount:Int):Int
    {
            return Std.int(getRandom() * amount);
    }

Recycling

EDIT: Checking the source here I see that I don't have the same version and there shouldn't be a problem with the collide. Must have made a mistake when I tried to update.

Recycling works with this change to the create function,

    /**
     * Returns a new Entity, or a stored recycled Entity if one exists.
     * @param   classType       The Class of the Entity you want to add.
     * @param   addToWorld      Add it to the World immediately.
     * @return  The new Entity object.
     */
    public function create(classType:Dynamic, addToWorld:Bool = true):Entity
    {
        var className:String = Type.getClassName(classType);
        var fe:FriendEntity = _recycled.get(className);
        if (fe != null)
        {
            _recycled.set(className, fe._recycleNext);
            fe._recycleNext = null;
        }
        else fe = Type.createInstance(classType, []);
        var e:Entity = cast(fe, Entity);
        if (addToWorld) return add(e);
        return e;
    }

Spritemap doesn't render

I seem to be having an issue with spritemap not displaying any data to the screen, the entity is there, however the image is not. :(

Here is the code I am using, pulled from the tutorial on the website. This code is in my entities added() function.

    _sprite = new Spritemap("gfx/ship.png", 18, 18);
    _sprite.add("idle", [0]);
    _sprite.play("idle");
    this.graphic = _sprite;

Just for good measure, the image data appears appropriately when using this code instead.

    this.graphic = new Image("gfx/ship.png");

I am using haxe 2.10, nme 3.4.0, and HaxePunk 1.6.6 from haxelib.

Scaled originX/Y values on native targets

The update to hardware acceleration messed up the offset values for images and sprites. When scaling the x/y values it is also scaling the originX/Y values as well.

Call threshold prevents all atlas-based images from rendering

In Atlas.PrepareTile:

[code]if (_layer.index > drawCallThreshold)
{
_layer.prepare();
getSpriteByLayer(layer).graphics.drawTiles(_tilesheet, _layer.data, smooth, _renderFlags);
}[/code]

Shouldn't that > be changed to a <? I was unable to get my atlas-based Images to render until I made that edit.

Android : Game crashes when playing too much sounds.

When playing too much sounds at once the game crashes on Android, not on other platforms.

You can recreate this error by too sounds at once or rapidly playing them.

When running in debug mode on Android, the console on the pc gives me this error :

E/AndroidRuntime(10114): FATAL EXCEPTION: GLThread 861
E/AndroidRuntime(10114): java.lang.NoSuchMethodError: no static method with name
='getSoundPosition' signature='(II)I' in class Lorg/haxe/nme/Sound;
E/AndroidRuntime(10114): at org.haxe.nme.NME.onRender(Native Method)
E/AndroidRuntime(10114): at org.haxe.nme.MainView$Renderer.onDrawFrame(Ma
inView.java:358)
E/AndroidRuntime(10114): at android.opengl.GLSurfaceView$GLThread.guarded
Run(GLSurfaceView.java:1516)
E/AndroidRuntime(10114): at android.opengl.GLSurfaceView$GLThread.run(GLS
urfaceView.java:1240)
E/DASH - ak897x( 403): ak897x_activate: unable to set accelerometer delay!

Lamba.indexOf() creating garbage?

While testing the profiler in Flashdevelop I noticed that memory would steadily increase even while not doing anything. Looking through the objects it seems that, as far as I can tell, lots of functions are built up over time causing memory to go up (from 50MB up to about 100MB in my case).

Image with the profiler ( just noticed memory use is cropped out by accident) and what I belive is the function that is created all the time:

http://imgur.com/lNjG4

Draw.rect() doesn't draw anything

Bug tested on 2.1.1 and reported here http://forum.haxepunk.com/index.php?topic=312.0

The problem come from this line :
if (color < 0xFF000000) color = 0xFF000000 | color;

I'm not sure what you wanted to do here (and this method is quiet different from the FlashPunk one) but here is a solution that work. 0xFF000000 is equal to -16777216 in base 10. So it will almost never be true. Change the previous by this one :
color = 0xFF000000 | (0xFFFFFF & color);

The color will be displayed correctly, even if the user gives a value with an alpha channel as argument (it will be ignored).

If you don't like this behavior, and want to let the user set an alpha channel in the color, even though ' alpha ' (method's argument) is set to 1, then use this line instead to check if the color has an alpha channel
if ((color >> 24) & 0xFF == 0) color = 0xFF000000 | color;


On a side note, the second ' if ' of the method is useless :
if (color >= 0xFF000000) color = 0xFFFFFF & color;
Once again, 0xFF000000 == -16777216, so it will be true almost every time.

EDIT: completely changed my message after reading about colors and bitwise stuff.

Understanding mouseX and mouseY

Sorry to keep hurling these at you :)

Currently, I am running into either a bug with mouseX, or a simple misunderstanding of what mouseX is supposed to give me. Here is a build with the bug, and here is the source code. It's present on the Handle element below the Radio buttons on the left side. Also, the source code is currently using mouseFlashX, but the issue is still the same regardless.

When I select that bar to move, rather than use the pointer side of the my OS's mouse graphic, mouseX uses the opposite side. Besides the obvious issue of not going where the user wants it to, there is another oddity that deals with collidePoint and mouseX. When using collidePoint, the correct side of the mouse graphic is used, so this causes the range of the Handle slider to be shifted to the right equal to the width of the mouse graphic, meaning I can't reach the far left side, and the slider moves off the edge of the far right side.

Image.scale not being used when rendering atlas

_region.draw(_point.x, _point.y, layer,
HXP.screen.fullScaleX * scaleX * (_flipped ? -1 : 1),
HXP.screen.fullScaleY * scaleY,
angle);

I think each scaleX and scaleY is missing being multiplied by scale

Grid and Tilemap performance is worse than using idividual "wall" entities

Using a Grid mask, I'm getting worse performance than using individual entities. I'm using a 640x480 grid with 16x16 tiles. Unfortunately, I'm programming in spanish (it's first time this noobish mistake is a problem), so my code could be pretty hard to read if I copy-pasted it here.
Actually, this same thing happens with tilemaps. Here's some code explaining this better:

//Creating the world like this:
...
switch(level_data[i][a])
{
    case WALL:
    myTilemap.setTile(i,a,0);
    myGrid.setTile(i,a,true);
}
...
add(new Entity(0,0,myTilemap,myGrid)).type=Main.TYPE_WALL;

//...makes the update() loop slower than creating the world like this:

switch(level_data[i][a])
{
    case WALL:
    add(new Wall(i*16,a*16));// i*16/a*16 being the x/y position
}

The Grid and Tilemap classes need to be optimized or wiped out the lib, as their purpose is to make the game faster than using individual entities.
http://dl.dropbox.com/u/45951683/github%20grid%20issue.zip

Here are two .swf's of my WIP game. An swf uses Grid and Tilemap and the other one uses individual entities.

I'll be glad to help if you can't reproduce this problem. I might even take a look at the source files and try to optimize both classes later.

Request: add word wrapping to Text

Currently, as far as I know, the only way to wrap a string is via manual placement of \n. FlashPunk seems to have a word wrapping feature; and it doesn't look too difficult to implement.

It seems also that you skipped over the options section. Haxe has anonymous objects, so there shouldn't be anything fancy required to get that up and running.

I might try fixing up Text myself, but I'd rather wait until my other pull requests get attention instead of adding a new random feature to it.

Text change/resize problem

It appeared broken as below, when the text of a Text is modified.

C++ (Mac):

Screen Shot 2013-01-22 at 5 55 22 PM

Flash:

Screen Shot 2013-01-22 at 6 09 18 PM

Here is the sample code:

import com.haxepunk.*;
import com.haxepunk.graphics.*;

class TestWorld extends World {
    override public function begin():Void {
        super.begin();

        var text = new Text("Testing", { resizable: true });

        text.text = "TestingTestingTestingTesting";

        addGraphic(Image.createRect(text.textWidth, text.textHeight, 0xFF0000));
        addGraphic(text);
    }
}

class Main extends Engine {
    public function new():Void {
        super();
        HXP.world = new TestWorld();
    }

    static public function main():Void {
        nme.Lib.current.addChild(new Main());
    }
}

Switching scenes, then switching back doesn't work correctly in 2.2.0

First, I have confirmed that this issue was introduced in 2.2.0.

I have this code to create a scene and switch to it:
Main.ascene = new AScene();
HXP.scene = Main.ascene;

Later I switch to a new world:
HXP.scene = new BScene();

And switch back like this:
HXP.scene = Main.ascene;

Prior to 2.2.0, this worked perfectly and wold switch scenes exactly as expected. Now it seems to only half switch. AScene's update function is being called, and BScene is no longer the active scene, but any entities that were added to the scene before the switch don't appear to exist (not there visually and don't run update functions). New entities can be added, however.

scale Tilemap

The feature to scale a Tilemap would be useful in some cases.

Btw: Some labels for the github issues would be nice to at least differ between bugs and feature requests.

Tween.hx fixed/non-fixed framerate

In tween.hx l.53 is the following code :
_time += HXP.fixed ? 1 : HXP.elapsed;

I think fixedFramerate is when you have a timer driven update rate, so time should be mesured in elapsed time, and non-fixed framerate is drive by "onFrame" events and time should be mesured as +1 frame. I think the condition is swapped and the expecting code is :
_time += HXP.fixed ? HXP.elapsed : 1;

Setting width or height to anything non-default throws error on flash target

Tutorial defaults works properly, but setting Engine's width/height to anything (even in constructor) throws following:

An ActionScript error has occurred:
ArgumentError: Error #2015: Invalid BitmapData.
    at flash.display::BitmapData/ctor()
    at flash.display::BitmapData()
    at com.haxepunk::HXP$/createBitmap()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/HXP.hx:838]
    at com.haxepunk::Screen/resize()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/Screen.hx:65]
    at com.haxepunk::HXP$/resize()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/HXP.hx:228]
    at com.haxepunk::Screen/set_scaleX()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/Screen.hx:200]
    at com.haxepunk::Engine/resize()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/Engine.hx:223]
    at com.haxepunk::Engine/setStageProperties()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/Engine.hx:186]
    at com.haxepunk::Engine/onStage()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/Engine.hx:241]
    at com.haxepunk::Engine()[/home/dsirijus/Libraries/haxepunk/com/haxepunk/Engine.hx:96]
    at Main()[src/Main.hx:29]
    at Main$/main()[src/Main.hx:20]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at Function/<anonymous>()
    at Reflect$/callMethod()[/usr/lib/haxe/std/flash/_std/Reflect.hx:56]
    at ApplicationMain$/begin()[bin/flash/haxe/ApplicationMain.hx:69]
    at ApplicationMain$/preloader_onComplete()[bin/flash/haxe/ApplicationMain.hx:96]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at NMEPreloader/onLoaded()[bin/flash/haxe/NMEPreloader.hx:98]
    at ApplicationMain$/onEnter()[bin/flash/haxe/ApplicationMain.hx:88]

Text class breaking the game

Doing graphic = new Text("hi"); currently breaks the game. The native Windows build stops responding immediately and the flash build just doesn't show anything.

Unable to output html5 of template

When trying to output the haxepunk template to html5, it fails first with this error:
Called from ? line 1
Called from be/haxer/hxswfml/Main.hx line 242
Called from be/haxer/hxswfml/FontWriter.hx line 164
Called from format/ttf/Reader.hx line 27
Called from format/ttf/Reader.hx line 89
Called from C:\Motion-Twin\haxe/std/haxe/io/Input.hx line 237
Called from C:\Motion-Twin\haxe/std/haxe/io/BytesInput.hx line 61
Uncaught exception - Eof

and when you remove font assets from the nmml, it errors with this:
haxelib/HaxePunk/1,6,5/com/haxepunk/debug/Console.hx:361: characters 2-63 : Invalid arguments
haxelib/HaxePunk/1,6,5/com/haxepunk/debug/Console.hx:361: characters 2-63 : Function 'draw' requires arguments : source, ?matrix, ?colorTransform, ?blendMode, ?clipRect, ?smoothing

It's really important to me to have a working html5 exporter.

Image cliprect with AtlasRegion doesn't work.

You can't really define a sub-region of an AtlasRegion because it is a limitation with the TileSheet class. It simply can't be done as of now.

The most obvious solution is to simply create a new AtlasRegion that is a subregion of the original. To do this you need:

  • access is needed to the AtlasRegions parent.
  • access to the AtlasRegions name.
  • access to the AtlasRegions x and y values.

Maybe there is clipping somehow possible with drawtiles, but my googling has turned up nothing.

EDIT: It may even be advisable to have access to an AtlasRegion's sub-regions with the AtlasRegion itself. This could allow TileMaps to be passed an AtlasRegion instead of a bitmap. The benefit here is several parallax tilemaps could be drawn within a single draw call with a whole lot of other Graphics.

Rotated sprites in a texture atlas.

When using TexturePacker, if you create an atlas with rotated sprites, there are numerous issues with hardware rendering. The images created with cannot be rotated, scaled, or their origins changed reliably. Also, their y position is always off when rendered without the aforementioned properties modified.

I tried fix the issue by reworking a large portion of the rendering code to no avail. It could be done by someone with better maths than me so maybe someone can pull it off.

This is what needs to happen on the math side during rendering for rotation in the atlas to work:

rotate 90
translate height (this resets the origin to the top left)
translate originx/y
scalex/y
rotate angle

The problem shows up during translation. You cannot translate with the 2x2 matrix available through drawTiles. You need a 3x3 matrix for translations. The math has to be done by hand which would add a lot of unnecessary congestion to the rendering code. Although, performance-wise, on native it probably won't make THAT much of a difference.

Then again, I might be wrong. Tell me I am wrong and it can be done. Please...

Funktion and num keys are not working on windows

The F(unktion) and num keys are not working on cpp windows build,
on flash everything is fine.

I get 80 as keycode for F1 on windows, which is equivalent to Key.P

if (Input.pressed(Key.F1))
    trace("F1");

if (Input.pressed(80)) // equals Key.P
    trace("F1 - Win");

if (Input.pressed(Key.NUMPAD_0))
    trace("NUM 0");

Ghost text on flash target

Creating a Text object on flash does always produce a ghost text at position 0, 0 with the same text.

var txt:Text = new Text("Test", 100, 100);
addGraphic(txt);

Without the addGraphic line the ghost is shown only.

screenshot

originX/originY doesn't work on native targets.

I'm trying to set the origin of a spritemap in HaxePunk 2.1.1, but it only seems to work on flash.
Doesn't work on Windows, Windows Neko and Android.

For example, when I set the originX and originY of a Spritemap, the sprite stays at its original origin (0,0) instead of the origin I set.
It looks funny because it turns around the center thereby dragging the entire sprite around its axis. For more details on how it looks I included some screenshots :

Super Awesome Space Shooter flash
Super Awesome Space Shooter windows -neko

If this is already fixed in the next version , disregard this issue.

VarTween and MultivarTween bug on Haxe 2.10

They gives me an error: "On static platforms, null can't be used as basic type Float"
to fix it you need to replace the line:
if (a == null)
with:
if (Reflect.getProperty(_object, property) == null)
in both files in tween() methods (line 45 in VarTween and line 57 in MultivarTween)

Neko compilation bug

When trying to test my Clash demo on a Linux/Neko target, I get this error:

Couldn't set OpenGL mode: Couldn't find matching GLX visual
Called from sys.io.FileOutput::$statics line 1
Called from ApplicationMain::main line 39
Called from neash.Lib::create line 64
Called from neash.display.Stage::nmeProcessStageEvent line 358
Called from neash.display.Stage::nmeDoProcessStageEvent line 270
Called from neash.display.Stage::nmePollTimers line 651
Called from neash.display.Stage::nmeCheckRender line 228
Called from neash.display.Stage::nmeRender line 663
Called from neash.display.DisplayObjectContainer::nmeBroadcast line 129
Called from neash.display.DisplayObjectContainer::nmeBroadcast line 129
Called from neash.display.DisplayObjectContainer::nmeBroadcast line 142
Called from neash.display.DisplayObject::nmeBroadcast line 248
Called from neash.display.DisplayObject::nmeDispatchEvent line 259
Called from neash.events.EventDispatcher::dispatchEvent line 80
Called from neash.events.Listener::dispatchEvent line 177
Called from com.haxepunk.Engine::onEnterFrame line 232
Called from com.haxepunk.Engine::update line 115
Called from com.haxepunk.Engine::checkWorld line 318
Called from Test::begin line 29
Called from clash.Button::$init line 18
Called from clash.Button::new line 43
Uncaught exception - Invalid field access : __construct__

It compiles to both Linux/CPP and Flash, so there seems to be something wrong with the Neko target. The source code for the issue is in my Clash repository, with the issue seeming to come from the Button class.

I wish I had more to tell you, but I don't really know what the issue is.

Image placement in 2.1.0+ (on at least android, because of HXP.screen.width/height?)

I have code that looks like this:

highscoresText.x = (HXP.screen.width * .5) - (highscoresText.textWidth * .5);
highscoresText.y = (HXP.screen.height * .65);

This works fine in all versions of HaxePunk on the flash target, placing the text centered nicely. However, the text is in the wrong place on android using HaxePunk 2.1.0 and up (I haven't tested other devices, such as iOS or Blackberry). The text appears much lower, and to the right of where it should, nearly off the screen in fact.

Draw.linePlus crash in NME

When calling lineStyle in Draw.linePlus it causes a crash on Windows.

com.haxepunk.Draw:175
Graphic.lineStyle

Flipping images

Discovered that I hadn't tested the flipping properly. When two or more images tries to be flipped it will only over use the first image that gets flipped. This is because a hash is used to store the images and since all the bitmapdata objects have the name "BitmapData" the same iamge will be used. I have tried to come up with something to fix it but I can't come up with an idea that works neatly due to bitmapData not having a unique identifier.

The two fixes I have come up with is either:

  1. When creating a new image (or a class that extends Image) you also pass an (optional?) identifier that is used as the _class variable.

  2. Pass in Bitmaps instead of only the bitmapData and rely on HXP.getBitmap() ( I believe it would need some changes or a new function would be made).

(This is while using Samhaxe, may be other ways otherwise).

Possible memory leak with Image class

So I noticed a memory leak in my Clash UI project, and I don't really see where there could be a problem in my code to cause it. If I toggle between different skins, my memory goes up each time. When I talked about (something similar) to this on the forums, you said that all Graphics classes pull from a cache of bitmap data, so I wouldn't think there would be any change in memory after the first call to a new set of bitmap data.

Is the new memory just the overhead of the Image class, not necessarily the bitmap data? Here is the current Flash build of Clash, with the debug information visible to show the leak (if you are using FDB).

Flash 9 BitmapData Limitation of 2880x2880

Hello,

Great work you've done here! Look forward to building my next game with HaxePunk. :-)

I ran into a problem tonight with your Canvas class. It was throwing an "Error 2015: Invalid BitmapData." Here's the stack trace:

ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData/ctor()
at flash.display::BitmapData()
at com.haxepunk.graphics::Canvas()[src/com/haxepunk/graphics/Canvas.hx:57]
at com.haxepunk.graphics::Tilemap()[src/com/haxepunk/graphics/Tilemap.hx:44]
at com.haxepunk.tmx::TmxEntity()[src/com/haxepunk/tmx/TmxEntity.hx:57]

It seems when using Flash 10, the limitation on BitmapData is 4096x4096, and you have an arbitrary limit of 4000 set by default on line #32 of Canvas.hx, which is great:

_maxWidth = _maxHeight = 4000;

But on Flash 9, this breaks when you attempt to load an image greater than 2880x2880 because Flash 9 imposes a different size limitation. I was able to fix this for Flash 9 simply by changing this line to:

if flash9

    _maxWidth = _maxHeight = 2880;

else

    _maxWidth = _maxHeight = 4000;

end

Hope this helps.

Thanks,
Marc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.