crappy-coder / astrid

2D Game Engine and Application Framework
2 stars 0 forks source link

Get examples working with new source #14

Open fabslab opened 9 years ago

fabslab commented 9 years ago

Let's start migrating the examples in /archive/examples to /examples as we get them working with the new code. They will have to import whatever they need from the src. I'll start with the MoAnimation.html.

fabslab commented 9 years ago

So I moved over the animation example. However when running it I found there's an issue with the circular dependency between PathSegment and PathLineSegment. PathSegment requires PathLineSegment and PathLineSegment extends PathSegment. When PathLineSegment tries to extend PathSegment it can't since it's undefined (PathLineSegment is initialized before PathSegment).

PathSegment creates instances of PathLineSegment (its subclass) within its methods. I feel that's strange, perhaps unintentionally coupling too explicitly, do you think we can change things around a bit there to avoid that?

fabslab commented 9 years ago

For now I'm just replacing new PathLineSegment( in PathSegment with new this.constructor(. So that if it is an instance of PathLineSegment it will work as normal. I'm guessing instances of just PathSegment aren't created, that you're using it as an abstract class instead. I haven't really checked though.

fabslab commented 9 years ago

Okay I've got the example to load without any exceptions and it appears to be running but nothing is drawn to the canvas dom element so don't see anything. Feel free to help me debug - https://github.com/JTJustCodes/astrid/tree/example-animation. Run the /examples/animation/index.html file.

fabslab commented 9 years ago

I think it's the way the Animatable is mixed in, I think its empty initializeAnimatablePropertiesCore method is overwriting the existing one in the Drawable for some classes that extend Drawable then mix in Animatable. I'm trying to remove the empty method from Animatable and work out something else atm. Need to look back at Prototype.js and see how it was mixing it in without overwriting, or maybe it was and the problem is something else.

fabslab commented 9 years ago

Okay yeah, the order the mixins were done with Class.create in Prototype.js is different to the way I did it.. gonna fix that..

fabslab commented 9 years ago

I committed a mixin function and changed it to do that stuff properly, still not seeing anything so gonna keep debugging later.

fabslab commented 9 years ago

From a quick look I see the process method in LayoutManager isn't getting called.

crappy-coder commented 9 years ago

Oh I believe the timer class will need to be fixed, I can take a look real quick.

-JT

On Aug 2, 2015, at 10:34 AM, Fabien notifications@github.com wrote:

From a quick look I see the process method in LayoutManager isn't getting called.

— Reply to this email directly or view it on GitHub.

crappy-coder commented 9 years ago

Ya, PathSegment is a base/abstract class, but the PathLineSegment should be created at runtime. Might need to move that out somewhere or figure out how to resolve singular circular imports.

-JT

On Aug 1, 2015, at 11:05 PM, Fabien notifications@github.com wrote:

For now I'm just replacing new PathLineSegment( in PathSegment with new this.constructor(. So that if it is an instance of PathLineSegment it will work as normal. I'm guessing instances of just PathSegment aren't created, that you're using it as an abstract class instead. I haven't really checked though.

— Reply to this email directly or view it on GitHub.

fabslab commented 9 years ago

Yeah I committed a fix for that that just uses whatever the constructor is at runtime to create the instance. On 2 Aug 2015 11:50 am, "JT" notifications@github.com wrote:

Ya, PathSegment is a base/abstract class, but the PathLineSegment should be created at runtime. Might need to move that out somewhere or figure out how to resolve singular circular imports.

-JT

On Aug 1, 2015, at 11:05 PM, Fabien notifications@github.com wrote:

For now I'm just replacing new PathLineSegment( in PathSegment with new this.constructor(. So that if it is an instance of PathLineSegment it will work as normal. I'm guessing instances of just PathSegment aren't created, that you're using it as an abstract class instead. I haven't really checked though.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/JTJustCodes/astrid/issues/14#issuecomment-127053310.

fabslab commented 9 years ago

Yeah looks to be an issue in Timer, the TimerEvent.Tick event never gets didpatched inside onTimerCallback. On 2 Aug 2015 11:51 am, "Fabien Brooke" fabienbrooke@gmail.com wrote:

Yeah I committed a fix for that that just uses whatever the constructor is at runtime to create the instance. On 2 Aug 2015 11:50 am, "JT" notifications@github.com wrote:

Ya, PathSegment is a base/abstract class, but the PathLineSegment should be created at runtime. Might need to move that out somewhere or figure out how to resolve singular circular imports.

-JT

On Aug 1, 2015, at 11:05 PM, Fabien notifications@github.com wrote:

For now I'm just replacing new PathLineSegment( in PathSegment with new this.constructor(. So that if it is an instance of PathLineSegment it will work as normal. I'm guessing instances of just PathSegment aren't created, that you're using it as an abstract class instead. I haven't really checked though.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/JTJustCodes/astrid/issues/14#issuecomment-127053310.

crappy-coder commented 9 years ago

Even with the commit I pushed a little bit ago?

-JT

On Aug 2, 2015, at 12:28 PM, Fabien notifications@github.com wrote:

Yeah looks to be an issue in Timer, the TimerEvent.Tick event never gets didpatched inside onTimerCallback. On 2 Aug 2015 11:51 am, "Fabien Brooke" fabienbrooke@gmail.com wrote:

Yeah I committed a fix for that that just uses whatever the constructor is at runtime to create the instance. On 2 Aug 2015 11:50 am, "JT" notifications@github.com wrote:

Ya, PathSegment is a base/abstract class, but the PathLineSegment should be created at runtime. Might need to move that out somewhere or figure out how to resolve singular circular imports.

-JT

On Aug 1, 2015, at 11:05 PM, Fabien notifications@github.com wrote:

For now I'm just replacing new PathLineSegment( in PathSegment with new this.constructor(. So that if it is an instance of PathLineSegment it will work as normal. I'm guessing instances of just PathSegment aren't created, that you're using it as an abstract class instead. I haven't really checked though.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/JTJustCodes/astrid/issues/14#issuecomment-127053310.

— Reply to this email directly or view it on GitHub.

fabslab commented 9 years ago

Ah I didn't see it, lemme test it out

fabslab commented 9 years ago

That looks good. Now its got an error in PathCubicBezierSegment, getTangent is being called and this.curvePoints is null so there's an exception. I see it gets set in getCurvePoints and nothing calls that.

fabslab commented 9 years ago

I'll just call the getCurvePoints within getTangent to set it. Looks like that's what the old version in the archive examples was doing.

crappy-coder commented 9 years ago

Right, the first line of getTanget should be "var curvePoints = this.getCurvePoints(prevSegment);"

–* JT*

On Sun, Aug 2, 2015 at 2:06 PM, Fabien notifications@github.com wrote:

I'll just call the getCurvePoints within getTangent to set it. Looks like that's what the old version in the archive examples was doing.

— Reply to this email directly or view it on GitHub https://github.com/JTJustCodes/astrid/issues/14#issuecomment-127071925.

fabslab commented 9 years ago

Dude now it workssssssss

fabslab commented 9 years ago

I committed the animation example to master and added steps to the readme on how to run it. I'll start doing the bubbles one soon.

crappy-coder commented 9 years ago

Haha that's awesome!

-JT

On Aug 2, 2015, at 2:17 PM, Fabien notifications@github.com wrote:

Dude now it workssssssss

— Reply to this email directly or view it on GitHub.

fabslab commented 9 years ago

The bubbles example has the black background and fps graph but none of the bubbles show up. https://github.com/JTJustCodes/astrid/tree/bubbles Don't see any exception

fabslab commented 9 years ago

One thing I see is that in LayoutManager it removes this handler and then never adds it back app.removeEventHandler(FrameEvent.ENTER, this.handleFrameTickEvent.asDelegate(this)); in handleFrameTickEvent()

fabslab commented 9 years ago

bubbles is working now.. merged it into master. was a silly mistake on my part, forgot to rename the initialize method to constructor when i changed it to class syntax lol..

fabslab commented 9 years ago

what's the next example we should get working homedog?