Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by y0ungb0b

Hi,

I was wondering if using Coffeescript with Impact was a good idea. I noticed some users on this forum have posted Coffeescript snippets.

However, I just had a quick go at coding a test entity in CS and I get a 'can't spawn entity of type <entity name>' error.

Any tips/help appreciated. Cheers.

1 decade ago by ghedamat

I was trying the same today

Apparently Impact uses global variables for class names

as in EntityPlayer, but coffescript forbids that and wraps everything in closures..

I'm looking to a workaround right know..

1 decade ago by ghedamat

woops, was really easy of course :D

ig.module("game.entities.player")
.requires(
 "impact.entity"
) 
.defines ->
  window.EntityPlayer = ig.Entity.extend

just attach the class definition to the window object...

anyway, weltmeister only loads entities from js files, so to have it working properly you need to compile the coffeescript files before using it...

1 decade ago by y0ungb0b

Thanks ghedamat, that works a treat!

1 decade ago by netmute

Or you could write it like this:

ig.module(
  'game.entities.player'
)
.requires(
  'impact.entity'
) 
.defines =>
  @EntityPlayer = ig.Entity.extend

1 decade ago by y0ungb0b

Quote from netmute
Or you could write it like this:

##
ig.module(
'game.entities.player'
)
.requires(
'impact.entity'
)
.defines =>
@EntityPlayer = ig.Entity.extend
##


This doesnt work for me. I get a "Reference Error - cant find variable x" when spawning entities.

1 decade ago by netmute

Mind the fat arrow after defines:
=>

it preserves the function scope.

1 decade ago by y0ungb0b

Doh! Missed that :-)
Thanks!

10 years ago by Zoneh

I know this is an old thread, but I found it on google so I'll just write here. Is there any way that I would be using CoffeeScript classes instead of impact modules? Any written library that would support this?

10 years ago by taddeimania

i've been writing an impact game in coffeescript and have long wanted to document my process in a blog post. i'll see about whipping something up over the next few days.

It's a pretty smooth process once you get over the few gotchas... especially if you want to build the game for Ejecta.

10 years ago by Zoneh

If you could share your knowledge in a post I would love to read it, and I think I'm not the only one!
Page 1 of 1
« first « previous next › last »