Created
January 6, 2014 21:44
-
-
Save addieljuarez/8290339 to your computer and use it in GitHub Desktop.
hola mundo lanica
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ApplicationWindow.js | |
| // lanicaSample | |
| // | |
| // Created by Addiel Juarez on 2014-01-02. | |
| // Copyright 2014 Addiel Juarez. All rights reserved. | |
| // | |
| function ApplicationWindow() { | |
| var lanica = require('co.lanica.platino'); | |
| var shapes = []; | |
| var self = Titanium.UI.createWindow({ | |
| backgroundColor:'#000', | |
| navBarHidden:true, | |
| fullscreen:true, | |
| }); | |
| var gameView = lanica.createGameView({ | |
| fps:100, | |
| debug:true, | |
| }); | |
| gameView.color(0,0,0); | |
| var touch_scale = 1; | |
| var scene = lanica.createScene(); | |
| gameView.pushScene(scene); | |
| gameView.addEventListener('onload', function(){ | |
| touch_scale = gameView.screen.width / gameView.size.width; | |
| gameView.registerForMultiTouch(); | |
| gameView.start(); | |
| }); | |
| function touchStart(e){ | |
| Titanium.API.info(e.type +' : '+ JSON.stringify(e.points)); | |
| for (var pointName in e.points) { | |
| if (typeof shapes[pointName] === 'undefined' || shapes[pointName] === null ) { | |
| shapes[pointName] = lanica.createSprite({ | |
| width:70, height:70, image:'images/troll.png' | |
| }); | |
| scene.add(shapes[pointName]); | |
| }; | |
| shapes[pointName].center = {x: e.points[pointName].x * touch_scale, y:e.points[pointName].y * touch_scale}; | |
| }; | |
| }; | |
| function touchEnd(e){ | |
| Titanium.API.info(e.type +' : '+ JSON.stringify(e.points)); | |
| var point; | |
| for (point in e.points) { | |
| if (typeof shapes[point] === 'undefined' || shapes[point] === null ) { | |
| Ti.API.info("Couldn't find touch: " + pointName); | |
| continue; | |
| } | |
| scene.remove(shapes[point]); | |
| shapes[point] = null; | |
| delete shapes[point]; | |
| }; | |
| if (e.type == 'touchend') { | |
| for (point in shapes) { | |
| if (typeof shapes[point] === 'undefined' || shapes[point] === null) { | |
| continue; | |
| }; | |
| scene.remove(shapes[point]); | |
| shapes[point] == null; | |
| }; | |
| shapes.length = 0; | |
| }; | |
| }; | |
| gameView.addEventListener('touchstart', touchStart); | |
| gameView.addEventListener('touchmove', touchStart); | |
| gameView.addEventListener('touchend', touchEnd); | |
| self.add(gameView); | |
| return self; | |
| } | |
| module.exports = ApplicationWindow; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment