Posts tagged: javascript

Games and What’s Going On

Heyall. So it has been almost three months since I last posted here? Ouch… Here’s what’s new.

Though I started the game just about a year ago, “Space Fight” development is on a bit of a break. It’s an ambitious project and for a guy like me who has never made a big ambitious project, it’s a lot of work. And since a lot of work takes a lot of time, my wife suggested maybe I should get something smaller out quicker (insert that’s what she said joke here). So in the meantime I’m learning how to develop for the Android platform with the book Beginning Android Games. My wife and I brainstormed what we think may be a fun little game for touch screens so I’ll be making a small game for Android before moving on to the bigger more ambitious projects.

Kev Glass has started to flip my world upside down now with his HTML5 version of Legends of Yore! He has written the game in Java and compiled it into Javascript using GWT and the canvas widget. How cool is that? It’s significant for me as I was going to look into HTML5 game development but it appears that now you can just code your game using Java2D and have it compiled into Javascript and runnable on all manner of platforms (iPhone, Android, WebOS, PC, etc) right away.

I suppose the best course of action may be to finish Space Fight in it’s current framework and worry about porting it over to Java2D later. But first I learn Android development!

Mouse-following text

There are too many “Look at this text wiggle as it follows your mouse cursor” tutorials out there. They are outdated and who really wants to clog up their site with tacky cursor-following-wiggly-text?!

If you’re looking for static text that follows your cursor, and an easy-to-follow tutorial to show you how then look no further than this tutorial on About.com.

Google and jQuery (and others)

I’ve spent the last 30 minutes Googling for help to use Google’s AJAX Libraries API. You know what? The solution was right there on that page.

My problem was that I could get a jQuery example to work if I loaded the API like this

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" >
	// Do whatever
</script>

but I couldn’t get the example to work if I used the recommended

<script src="http://www.google.com/jsapi"></script>
<script>
	google.load("jquery", "1.2.6");
	// Do whatever
</script>

Are you in the same boat? Short and simple, here’s the solution:

<script src="http://www.google.com/jsapi"></script>
<script>
	google.load("jquery", "1.2.6");

	google.setOnLoadCallback(function() {
		// Do whatever
	});
</script>

Yep, you’ve got to put all your jQuery code inside the google.setOnLoadCallback method. Use the following to test that it works for you.

<html>
	<head>
		<script src="http://www.google.com/jsapi"></script>
		<script>
			google.load("jquery", "1.2.6");

			google.setOnLoadCallback(function() {
				$("a").click(function(event){
					event.preventDefault();
					$(this).hide("slow");
				});
			});
		</script>
	</head>
	<body>
		<a href="http://jquery.com/">jQuery</a>
	</body>
</html>

Staypressed theme by Themocracy