|
Viewing 1 to (15 Total) |
|
Great, thanks.
Posted on June 26, 2012 at 4:24 AM
|
|
Shouldn't neash.events.Event have a preventDefault() method?
Posted on June 19, 2012 at 4:58 AM
|
|
Thanks guys, solved my problem here. One interesting thing to share:
// fill alpha = 0 does not work on CPP
_hit = new Sprite();
_hit.graphics.beginFill(0x000000, 0);
_hit.graphics.drawRect(0, 0, 160, 180);
_hit.graphics.endFill();
_hit.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
// fill alpha = 1 and alpha = 0 works fine on CPP
_hit = new Sprite();
_hit.graphics.beginFill(0x000000);
_hit.graphics.drawRect(0, 0, 160, 180);
_hit.graphics.endFill();
_hit.alpha = 0;
_hit.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
Posted on June 18, 2012 at 10:49 AM
|
|
Investigating a bit further, I found that if I added a fill to the movieClip shape it would trace the width correctly.
Shame it took me so long to find it out. Here is the conclusion in search-friendly terms:
SWF Library + MovieClip + outline shape = no width or height
SWF Library + MovieClip + shape with fill = correct width and height
Posted on June 18, 2012 at 9:57 AM
|
|
I was having problems listening to custom events in NME 3.3.3 targeting CPP and I realised the problem was in the addEventListeners arguments:
_level.addEventListener(CustomEvent.SHOT_STARTED, onShotStarted, false, 0, true); // doesn't work
_level.addEventListener(CustomEvent.SHOT_STARTED, onShotStarted); // works
Hope it helps other people.
Posted on June 18, 2012 at 9:50 AM
|
|
Hi,
I'm having a problem with the SWF Library when compiling for Android. MovieClip width comes as zero.
var swf:SWF = new SWF(Assets.getBytes("assets/swf/library.swf"));
var movieClip:MovieClip = swf.createMovieClip("myMC");
var nestedClip:MovieClip = cast _movieClip.getChildByName("nestedMC");
trace(nestedClip.width); // outputs 0
It traces the correct width when I target Flash, I assume it's because format.swf.MovieClip extends flash.display.Sprite.
Is there anything I can do to get the correct width of the MovieClip on CPP?
Posted on June 18, 2012 at 8:38 AM
|
|
Are masks working in android target?
Posted on June 14, 2012 at 1:28 PM
|
|
Thanks Jon, B2PolygonShape.asEdge does the job.
For the other viewers, in the example above, just replace the edge line by this:
var edge:B2PolygonShape = B2PolygonShape.asEdge(new B2Vec2(50 * WORLD_SCALE, 50 * WORLD_SCALE), new B2Vec2(30 * WORLD_SCALE, 30 * WORLD_SCALE));
About 2-sided polygons being used in newer versions of Box2D instead of edges, isn't it the other way around?
The method AsEdge() is not part of the current b2PolygonShape.cpp and the only mentions about it in the Box2D forums are 2 years old.
As for edge shapes, they are part of the manual and Erin Catto posted something about them just 2 months ago.
My understanding is that Box2DFlashAS3 2.1a is a bit outdated - and consequentially box2d-haxelib too.
Anyway, thanks again for the reply, B2PolygonSgape.asEdge is what I needed to move on with the project.
Posted on May 28, 2012 at 4:56 PM
|
|
Hi Hugh,
You're right, it's the m_shape that is null.
Still, I don't know what to do with this.
The code is ok to create other types of shapes (circle, box) but it doesn't work for edges.
Why is m_shape null? Something missing in my body creation code above? Or something wrong with the B2EdgeShape implementation?
Thanks.
Posted on May 21, 2012 at 9:42 AM
|
|
Hi Hugh,
Thanks for you reply.
box2D/dynamics/B2Fixture.hx line 319:
m_shape.computeAABB(m_aabb, xf);
I have looked at it before and it seems that it can't get the AABB of my shape.
I would expect the code above to create an edge shape from (50, 50) to (30, 30). Maybe I can't initialize edge shapes like that?
In Box2D forums, I found posts like this from Erin Catto where an edge shape is initialized like this:
b2BodyDef bd;
ground = m_world->CreateBody(&bd);
b2EdgeShape shape;
shape.Set(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f));
ground->CreateFixture(&shape, 0.0f);
I could't find any documentation or examples on how to use B2EdgeShape on box2d-haxelib (or Box2DFlashAS3) so it is hard to know what is going wrong.
Are edge shapes implemented differently? Can you point me to an usage example?
Cheers
Posted on May 17, 2012 at 4:52 AM
|
|
I developed a game in Flash using Box2D Flash Alchemy Port and I started to port it to mobile using NME and box2d-haxelib. The first tests on my Android phone got me really excited, but I'm finding some blockers now that I'm getting into the actual game build.
One of these is the edge shape. Searching the Box2D forum I found code samples (cpp, monkey) where edge shapes are used just like any other shape (circle, box), but it fails when I try with Haxe. It also fails when with Flash, so I posted the same question in Box2D Forums, but my goal is to get it working in Haxe, so I appreciate if you guys can help.
Quick code to reproduce the error:
package ;
import box2D.collision.shapes.B2CircleShape;
import box2D.collision.shapes.B2EdgeShape;
import box2D.common.math.B2Vec2;
import box2D.dynamics.B2Body;
import box2D.dynamics.B2BodyDef;
import box2D.dynamics.B2FixtureDef;
import box2D.dynamics.B2World;
import nme.display.Sprite;
import nme.Lib;
class MainEdgeShape extends Sprite
{
private var _world:B2World;
public static var WORLD_SCALE:Float = 1 / 30;
static public function main()
{
Lib.current.addChild (new MainEdgeShape());
}
public function new()
{
super();
_world = new B2World(new B2Vec2 (0, 10.0), true);
createEdge();
}
private function createEdge()
{
var bodyDef:B2BodyDef = new B2BodyDef();
bodyDef.position.set(10 * WORLD_SCALE, 10 * WORLD_SCALE);
var edge:B2EdgeShape = new B2EdgeShape(new B2Vec2(50 * WORLD_SCALE, 50 * WORLD_SCALE), new B2Vec2(30 * WORLD_SCALE, 30 * WORLD_SCALE));
//var edge:B2CircleShape = new B2CircleShape(20 * WORLD_SCALE); // B2CircleShape compiles fine
var fixtureDef:B2FixtureDef = new B2FixtureDef();
fixtureDef.shape = edge;
fixtureDef.density = 1;
var body:B2Body = _world.createBody(bodyDef);
body.createFixture(fixtureDef);
}
}
Runtime error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at box2D.dynamics::B2Fixture/createProxy()[C:\Motion-Twin\haxe\lib\box2d/1,11/box2D/dynamics/B2Fixture.hx:319]
at box2D.dynamics::B2Body/createFixture()[C:\Motion-Twin\haxe\lib\box2d/1,11/box2D/dynamics/B2Body.hx:131]
at MainEdgeShape/createEdge()[src/MainEdgeShape.hx:42]
at MainEdgeShape()[src/MainEdgeShape.hx:26]
at MainEdgeShape$/main()[src/MainEdgeShape.hx:19]
...
Cheers
Posted on May 16, 2012 at 1:02 PM
|
|
I have this library.swf with a few bitmaps inside. Some are .png with transparent areas and some are flat .jpg.
In both cases, when I load the SWF and export targeting Flash, I can see only the bitmaps which are exported with compression Lossless (PNG/GIF).
Is there support for bitmaps using Photo (JPEG) compression?
In case it helps, here's the output of my haxelib list:
actuate: 1.38 [1.40]
box2d: [1.11]
hxcpp: 2.08.1 2.08.2 2.08.3 [2.09]
jeash: [0.8.7]
nme: 3.2.0 3.3.0 [3.3.1]
swf: 1.07 1.10 [1.11]
Thanks.
Posted on May 01, 2012 at 6:25 AM
|
|
Thanks for the quick reply, Nomed. It was very helpful.
Also, in case other people have the same doubts, I found how to get deeper levels of nested clips.
Suppose MyButton with a clip named "background" in it. And inside background, another clip called "clouds".
I managed to get "clouds" by casting background to format.swf.MovieClip.
import format.swf.MovieClip;
var myButton = new MyButton();
var background:MovieClip = cast myButton.getChildByName("background");
var clouds = background.getChildByName("clouds");
---
About masks, apparently they have to be re-applied via code. What I did was to convert my shape mask in the .fla to a MovieClip, give it a name and also set a name to the masked object.
var myMask = myParentMC.getChildByName("myMask");
var myMaskedObj = myParentMC.getChildByName("myMaskedObj");
myMaskedObj.mask = myMask;
---
Posted on May 01, 2012 at 6:02 AM
|
|
Hi,
I have a few questions about the SWF library:
Suppose a MovieClip symbol called MyButton in library.fla. Inside this symbol, there are two other MovieClips, one with instance name "background" and another named "icon". In AS3 it would be possible to access both background and icon as separate MovieClips:
var myButton:MovieClip = [ some method to instantiate the loaded MyButton ] as MovieClip;
trace(myButton.background); // outputs [object MovieClip]
Is it possible to access nested MovieClips by instance name with haxelib swf?
Also, are masks supported? If so, where can I find instructions to make them work?
Thank you.
Posted on April 30, 2012 at 11:55 AM
|
|
Thanks for posting this. I was having the same problem and I was clueless about what to do.
It's working fine now.
Posted on March 03, 2012 at 5:17 PM
|