Skip to content

Commit

Permalink
Improved BitmapData restrictions for flash10
Browse files Browse the repository at this point in the history
  • Loading branch information
MattTuttle committed Apr 7, 2012
1 parent 7f01181 commit 4b1154a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -9,6 +9,7 @@ v1.6.2
* fixed several neko crash bugs (initialize to zero)
* Image.createRect fixed so it no longer creates a transparent image
* fixed circle-circle collision
* improved BitmapData size restrictions for flash10

v1.6.1
------------------------------
Expand Down
17 changes: 10 additions & 7 deletions examples/src/masks/GameWorld.hx
@@ -1,5 +1,6 @@
package masks;

import com.haxepunk.HXP;
import com.haxepunk.World;
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
Expand Down Expand Up @@ -37,9 +38,11 @@ class GameWorld extends World

public override function begin()
{
circle = createCircle(25, 25, 40, 0xFF0000FF);
// create a circle entity we can move around
circle = createCircle(25, 25, 30, 0xFF0000FF);

createCircle(300, 50, 50, 0xFFFF00FF);
// these are static objects
createCircle(300, 50, 150, 0xFFFF00FF);
createBox(150, 200, 50, 50, 0xFF00FFFF);
}

Expand All @@ -49,18 +52,18 @@ class GameWorld extends World
var x:Int = 0, y:Int = 0;

if (Input.check(Key.LEFT))
x = -5;
x = -8;

if (Input.check(Key.RIGHT))
x = 5;
x = 8;

if (Input.check(Key.UP))
y = -5;
y = -8;

if (Input.check(Key.DOWN))
y = 5;
y = 8;

circle.moveBy(x, y, "solid", true);
circle.moveBy(x, y, "solid");
}

var circle:Entity;
Expand Down
4 changes: 2 additions & 2 deletions src/com/haxepunk/HXP.hx
Expand Up @@ -695,10 +695,10 @@ class HXP
public static function createBitmap(width:Int, height:Int, ?transparent:Bool = false, ?color:Int = 0):BitmapData
{
#if flash
#if flash9
#if flash8
var sizeError:Bool = (width > 2880 || height > 2880);
#else
var sizeError:Bool = (width * height > 16777215); // flash 10 requires size to be under 16,777,215
var sizeError:Bool = (width * height > 16777215 || width > 8191 || height > 8191); // flash 10 requires size to be under 16,777,215
#end
if (sizeError)
{
Expand Down
2 changes: 0 additions & 2 deletions src/com/haxepunk/masks/Circle.hx
Expand Up @@ -10,8 +10,6 @@ import flash.geom.Point;
* Uses circular area to determine collision.
*/

using Std;

class Circle extends Mask
{
/**
Expand Down
8 changes: 4 additions & 4 deletions tests/TestMasks.hx
Expand Up @@ -30,17 +30,17 @@ class TestMasks extends haxe.unit.TestCase
{
// check that we collide with the circle
assertTrue(hitbox.collide("circle", 0, 0) != null);
assertTrue(hitbox.collide("circle", 20, 20) == null);
assertTrue(hitbox.collide("circle", 30, 30) == null);

circle.x = 40; circle.y = 40; // move circle out of the way

// this shouldn't collide at all with the circle
hitbox.moveBy(20, 20, "circle", true);
hitbox.moveBy(20, 20, "circle");
assertTrue(hitbox.x == 20 && hitbox.y == 20);

// this should collide with the circle and move 20 to the left only
hitbox.moveBy(20, 20, "circle", true);
assertTrue(hitbox.x == 40 && hitbox.y == 20);
hitbox.moveBy(20, 20, "circle");
assertTrue(hitbox.x == 40 && hitbox.y == 30);
}

private var world:World;
Expand Down

0 comments on commit 4b1154a

Please sign in to comment.