I don't think there's any convenient tutorial but...- You'll need to include xdate.js somewhere on the page before you include the scalajs javascript files.- If you have a class XDate() extends js.Object, then new XDate() in Scala translates into new XDate() in Javascript.- var definitions and uses on any extends js.Object classes map directly to attribute get/sets, def and val definitions and uses map to attribute gets.- Constructor params in the extends js.Object classes map to constructor params for the call to the javascript new XDate().- Secondary constructors work as you would expect. The body of constructors is ignored. val and var definitions in constructors do what you would expect.- class and object map to javascript classes and top-level-singleton objects.- By default the name of the class or object is used to reference the javascript class or top-level-singleton. You can use @JSName if you want to customize it to something else. @JSName works on methods too.- You can use @JSBracketAccess to make method calls that map to javascript thing[...] calls.Most of what I said is repeated here, and you can take a look at this if you want a non-contrived example of this in the wild. Basically you make something extends js.Object and it maps directly to a javascript thing of the same name, and constructors/variables/methods/etc. behave as you would expect.
--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Definitely suitable! A cookbook page under doc/ would be cool :-) Pull requests welcome!
--
You received this message because you are subscribed to a topic in the Google Groups "Scala.js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-js/rE1pQniDDlc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-js+u...@googlegroups.com.
--
OK, I hope to get started with this tonight. As for game ideas here are a few:
- Montana cabale/card game: the slightly 'boring' but easy and straightforward choice.
- Some variant of Angry Birds: potential to show how to create wrappers for Box2D.js or some other game JS engine and make something more impressive. No experience here so I don't know if it is out of scope requiring too much code.
- A tower defense game: different levels of complexity possible from predetermined paths, integration with physics engine, tower upgrade etc.
Also, it could be fun to integrate Scala.js into the theme of the game. For example, in the tower defense game the opponents could be the browser logos (IE being the slowest ;) and the towers could be X-to-JS compilers, e.g. Scala.js, Cofeescript, etc.
WDYT?
@JSName("PIXI.Stage")
class pixiStage(backgroundColor : String) extends js.Object {
def addChild(myChild : js.Any) : Unit = ???
}
@JSName("PIXI.autoDetectRenderer")
class pixiAutoDetectRenderer(screenWidth : Int, screenHeight: Int) extends js.Object {
var view : js.Any = ???
def render(myStage : js.Any) : Unit = ???
}
@JSName("PIXI.Text")
class pixiText(text : String, fontStyling : js.Dictionary) extends js.Object {
var width : Int = ???
var height : Int = ???
var visible : Boolean = ???
var position : js.Dictionary = ???
def setStyle(style : js.Dictionary) : Unit = ???
}
@JSName("PIXI.Graphics")
class pixiGraphics() extends js.Object {
var alpha : Double = ???
var position : js.Dictionary = ???
def lineStyle(lineWidth : Int, color : String, alpha : Double) : Unit = ???
def beginFill(color : String, alpha : Double) : Unit = ???
def beginFill(color : String) : Unit = ???
def endFill() : Unit = ???
def drawCircle(x : Int, y: Int, radius : Int): Unit = ???