Author Topic: Not totally a flixel related question, but kinda.[fixed, further face palming.]  (Read 1503 times)

zez

  • Active Member
  • ***
  • Posts: 203
  • Karma: +0/-0
    • View Profile
    • Devlog
How the hell do you get Mochi Scoreboards to work in a flxstate? Can you? Do I have to just bite the bullet and switch over to a movie clip or sprite and totally restart the game whenever you submit a score? That seems kinda lame...
« Last Edit: Sun, Apr 18, 2010 by zez »

haden.dude

  • Active Member
  • ***
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Not totally a flixel related question, but kinda.
« Reply #1 on: Sat, Apr 17, 2010 »
There is an example in the wiki:

http://wiki.github.com/AdamAtomic/flixel/mochiservices

It's based on the Mode game, it doesn't use the latest version of Flixel, but it shouldn't be too hard to understand how to use Mochi services.

zez

  • Active Member
  • ***
  • Posts: 203
  • Karma: +0/-0
    • View Profile
    • Devlog
Re: Not totally a flixel related question, but kinda.
« Reply #2 on: Sat, Apr 17, 2010 »
Yeah, I got the ad code to work fine using that, but none of the stuff that would actually happen in a state does. (This includes using the coin function included in the mode demo.)

haden.dude

  • Active Member
  • ***
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Not totally a flixel related question, but kinda.
« Reply #3 on: Sun, Apr 18, 2010 »
Yeah, I got the ad code to work fine using that, but none of the stuff that would actually happen in a state does. (This includes using the coin function included in the mode demo.)
That's weird, I'm using Mochi Leaderboards just fine. Here's the code of my Highscore State:
Code: [Select]
package states
{
import org.flixel.*;
import mochi.as3.MochiScores;
import flash.ui.Mouse;

public class HighscoreState extends FlxState {
[Embed(source = '../../data/sounds/music_loop_1.mp3')] private var MusicSnd:Class;
[Embed(source = '../../data/BackGround.png')] private var BackgroundImg:Class;

private var _score:int = -1;

public function HighscoreState(score:int = -1) {
_score = score;
}

override public function create():void
{
add(new FlxSprite(0, 0, BackgroundImg));

if (_score > 0) {
MochiScores.showLeaderboard( { boardID:"<your game id>", onDisplay:_onDisplay, onClose: _onClose, score:_score } );
} else {
MochiScores.showLeaderboard( { boardID:"<your game id>", onDisplay:_onDisplay, onClose: _onClose } );
}

FlxG.playMusic(MusicSnd);
super.create();
}

override public function update():void
{
Mouse.show();

super.update();
}

private function _onDisplay():void {
FlxG.mouse.hide();
Mouse.show();
}

private function _onClose():void {
Mouse.hide();
FlxG.mouse.show();
StateTransition.transition(TitleState);
}
}
}
You'll need to put your own game id. I use this state to submit a new score (by passing the score to the constructor), or to show the highscores (by calling the constructor without any parameter).
I did notice that MochiServices is very sensitive to the quality of the Internet connection, if its too slow it won't connect, but I think this happens only in my country...where slow connections are still allowed to live  :-\

zez

  • Active Member
  • ***
  • Posts: 203
  • Karma: +0/-0
    • View Profile
    • Devlog
Re: Not totally a flixel related question, but kinda.
« Reply #4 on: Sun, Apr 18, 2010 »
Gah, after tuns of brow furrowing, I realized my flxgame wasn't dynamic, so ofcourse changing the highscores state to dynamic didnt do anything...