--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, May 14, 2015 at 2:54 PM, Nick Stanchenko <nick....@gmail.com> wrote:
Note that when your Activity is recreated, you might want to recreate some of those things as well. In that case the “var” approach is the only way to go (although you can make it fancier by using Options).
Should those vars also be @volatile
, or does Android handle that?
Nick
On Wednesday, May 13, 2015 at 7:08:07 AM UTC+1, Sean Wolfe wrote:Worked great! here is the updated code.class Start extends Game {lazy val scalaImage = new Texture(Gdx.files.internal("scala.png"))lazy val camera = new OrthographicCamera()lazy val batch = new SpriteBatch()override def create() {camera.setToOrtho(false, 800, 480)}override def render() {Gdx.gl.glClearColor(0, 0, 0.2f, 1)Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)batch.setProjectionMatrix(camera.combined)batch.begin()batch.draw(scalaImage, 200, 200)batch.end()}}
On Tuesday, May 12, 2015 at 8:56:36 PM UTC-7, som-snytt wrote:lazy val image = if (created) new Texture else ???A lazy val is initialized once, lazily.To enforce that init is post-create, the initializer can throw if a flag isn't set.