Oct 212013

A very gentle introduction to Lanica’s Platino Game Engine, showing how to comment and display an image.The code below will show you how to;

  • Make a single line comment
  • Make a comment block
  • Set up a basic game scene
  • Display an image
  • Set the scene to fill various resolutions
  • Launch the game

You can run this code by downloading Platino, installing Platino, and making sure that you require it as a module in Titanium Studio.

Make sure you add your own image to the “Resources” folder that is created when you start a new mobile project.

// This is a comment
/* This
is a multiline
comment */
// Create a new window and make the app landscape
var window = Ti.UI.createWindow({
// Require Platino
var platino = require("co.lanica.platino");
// Create a view for your game (game.screen.width and game.screen.height will be set only once the game is loaded)
var game = platino.createGameView();
// Create a game scene
var scene = platino.createScene();
// Add a background image/bob which will fill the screen (z is for layering)
var background = platino.createSprite({x:0, y:0});
// Set the background color
// Add the background to the scene
// Create a new sprite (Specify image, or if you want a rectangle specify only width and height)
var bob = platino.createSprite({image:"bob.png", z:1});
// Add the sprite to the scene
// Add the scene to the game view
// Onload event is called when the game is loaded.
game.addEventListener('onload', function(e) {
    // Now game.screen.width and height have been set, use them to move your sprite to center of the screen
    bob.x = (game.screen.width  / 2) - (bob.width  / 2);
    bob.y = (game.screen.height / 2) - (bob.height / 2);
    // Set the size of the background based on the same
    background.width = game.screen.width;
    background.height = game.screen.height;
    // Start the game
// Add your game view to the window
// Open the window and hide the navigation bar
window.open({fullscreen:true, navBarHidden:true});

Stay tuned, I’ve got more very gentle introductions coming up. Plus, make sure you check out Lanica’s Show ‘N’ Tell Meetup, you can show what you’re doing with Platino, win prizes, or just check out what others are doing. This is an online and in person meetup, so even if you’re on the other side of the world, you can still attend!

Peach Pellen :)

  2 Responses to “Platino for Newbies Part 1: Displaying an Image”

  1. Keep it Up. Need some clarification on what it look like.

    • Hey Abhishek, thanks :-)

      When you say clarification on what it looks like, are you looking for a screenshot of the simulator running this code?

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>