Jump to content

[novice] having some issues with onInputHover, script dies.


Recommended Posts

I've never touched javascript before today, however I've got a fairly decent programming background, with about ten years of Java experience. I decided that I was going to make a nice, simply, turn-based rpg game, you know, like those games that are always advertised as pronz.


Anyway, when I try to add a hover effect, the script breaks (Things just stop, right there.)


Here's the full script:


<!DOCTYPE html><html><head><title>Online Turn-based RPG</title><link rel="stylesheet" type="text/css" href="css/style.css"><script type="text/javascript" src="js/phaser.min.js"></script></head><body><script type="text/javascript">var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update});function preload() {game.load.image('barracks', 'assets/town/barracks.gif');game.load.image('blacksmith', 'assets/town/blacksmith.gif');game.load.image('guild-hall', 'assets/town/guild-hall.gif');game.load.image('mill', 'assets/town/mill.gif');game.load.image('town-center', 'assets/town/town-center.gif');}function create() {game.add.sprite(25, 0, 'barracks');var mill = game.add.sprite(game.width - 50, 0, 'mill');mill.anchor.setTo(0, 0);mill.scale.x = -1;var towncenter = game.add.sprite(game.width / 2, game.height / 2, 'town-center');towncenter.anchor.setTo(.5, 1);towncenter.scale.x = -1;towncenter.inputEnabled = true;towncenter.events.onInputOver(glow, this);var blacksmith = game.add.sprite(25, game.height - 350, 'blacksmith');var guildhall = game.add.sprite(game.width - 50, game.height - 350, 'guild-hall');guildhall.anchor.setTo(0, 0);guildhall.scale.x = -1;}function update() {}function glow(sprite, pointer) {}</script></body></html>


Here's what it's supposed to look like:



However, when I added the lines:


towncenter.inputEnabled = true;towncenter.events.onInputOver(glow, this);


to my script, everything below the towncenter stopped drawing, example:




Link to comment
Share on other sites

towncenter.events.onInputOver.add(glow, this);

Should solve your issues.


Try using a developer console as well (for instance in chrome, or firebug in firefox etc)



I use Opera, as Chrome and Firefox completely destroy my computer for some reason; But after your recommendation I found dragonfly, thanks!

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...