Permalink
Browse files

Improved BitmapData restrictions for flash10

  • Loading branch information...
1 parent 7f01181 commit 4b1154abf3f796db16c9535d02bc5df0be185301 @MattTuttle committed Apr 7, 2012
Showing with 17 additions and 15 deletions.
  1. +1 −0 CHANGELOG
  2. +10 −7 examples/src/masks/GameWorld.hx
  3. +2 −2 src/com/haxepunk/HXP.hx
  4. +0 −2 src/com/haxepunk/masks/Circle.hx
  5. +4 −4 tests/TestMasks.hx
View
1 CHANGELOG
@@ -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
------------------------------
View
17 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;
@@ -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);
}
@@ -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;
View
4 src/com/haxepunk/HXP.hx
@@ -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)
{
View
2 src/com/haxepunk/masks/Circle.hx
@@ -10,8 +10,6 @@ import flash.geom.Point;
* Uses circular area to determine collision.
*/
- using Std;
-
class Circle extends Mask
{
/**
View
8 tests/TestMasks.hx
@@ -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;

0 comments on commit 4b1154a

Please sign in to comment.