Author Topic: flxbuttonplus intermitting  (Read 923 times)

arcade27

  • Member
  • **
  • Posts: 40
  • Karma: +0/-0
    • View Profile
flxbuttonplus intermitting
« on: Sun, Jul 31, 2011 »
ok :D *probably hated for number of help threads*

ok so ill explain the game flow first,  here is the flow of game states :D

mainmenu.as ----- >  Characterselect.as ------ > playstate.as  ( assuming they die )   -----> mainmenu.as

Now everything works PERFECT first time round.  but when you hit characterselect for the 2nd time.  non of my FLXbuttonpluss work X___X 
and ive been scratching my head at this for quite some time.


Code: [Select]
package 
{
//-------------------------------------------------------\
//OUR RECORSE IMPORTS
//-------------------------------------------------------/
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;
import org.flixel.plugin.photonstorm.FX.CenterSlideFX;
import org.flixel.plugin.photonstorm.FlxButtonPlus;
import org.flixel.plugin.photonstorm.FX.FloodFillFX;

public class characterselect extends FlxState
{
//-------------------------------------------------------\
//IMG IMPORTS
//-------------------------------------------------------/

//GLOBAL
[Embed(source = '../assets/titlepage.png')] private var titlePagePNG:Class;

//CHARATER SPECIFIC
//MELO
[Embed(source = '../assets/melo_button.png')] private var melo_button:Class;
[Embed(source = '../assets/melo_button2.png')] private var melo_button2:Class;
//REVE
[Embed(source = '../assets/reve_button.png')] private var reve_button:Class;
[Embed(source = '../assets/reve_button2.png')] private var reve_button2:Class;
//SOLI
[Embed(source = '../assets/soli_button.png')] private var soli_button:Class;
[Embed(source = '../assets/soli_button2.png')] private var soli_button2:Class;


//-------------------------------------------------------\
//Varables
//-------------------------------------------------------/

//=-=-=-Melo Button
//Images
private var melo_buttonflx:FlxSprite;
private var melo2_buttonflx:FlxSprite;
//button class
private var melob:FlxButtonPlus;

//=-=-=-Reve Button
//Images
private var reve_buttonflx:FlxSprite;
private var reve2_buttonflx:FlxSprite;
//button class
private var birdb:FlxButtonPlus;

//=-=-=-soli Button
//Images
private var soli_buttonflx:FlxSprite;
private var soli2_buttonflx:FlxSprite;
//button class
private var solb:FlxButtonPlus;

//=-=-=-Our mouse
private var mouse:Cursor;


//-------------------------------------------------------\
//Public Functions
//-------------------------------------------------------/
public function characterselect()
{

}

//-------------------------------------------------------\
//ON WORLD CREATE
//-------------------------------------------------------/
override public function create():void
{
if (FlxG.getPlugin(FlxSpecialFX) == null)
{
FlxG.addPlugin(new FlxSpecialFX);
}

mouse = new Cursor(FlxG.mouse.x, FlxG.mouse.y);

//-------------------------------------------------------\
//Lets Defein those Global Variables
//-------------------------------------------------------/
Registry.lifes = 3;
Registry.set_level = 1;
Registry.Character = 2;
FlxG.score = 0;
Registry.BP = 0;
Registry.SP = 0;
Registry.GP = 0;
//-------------------------------------------------------\
//And Those Buttons
//-------------------------------------------------------/

melo_buttonflx = new FlxSprite(0, 0, melo_button);
melo2_buttonflx = new FlxSprite(0, 0, melo_button2);

reve_buttonflx = new FlxSprite(0, 0, reve_button);
reve2_buttonflx = new FlxSprite(0, 0, reve_button2);

soli2_buttonflx = new FlxSprite(0, 0, soli_button2);
soli_buttonflx = new FlxSprite(0, 0, soli_button);


//-------------------------------------------------------\
//Then SEt them buttons up ;D
//-------------------------------------------------------/

solb = new FlxButtonPlus(10, 10, soli, null, "", 300);
solb.loadGraphic(soli_buttonflx, soli2_buttonflx);
birdb = new FlxButtonPlus(160, 10, birdi, null, "", 300);
birdb.loadGraphic(reve_buttonflx, reve2_buttonflx);
melob = new FlxButtonPlus(80, 110,meloi, null, "", 300);
melob.loadGraphic(melo_buttonflx, melo2_buttonflx);

//-------------------------------------------------------\
//A little music
//-------------------------------------------------------/

FlxG.playMusic(titleMusicMP3, 1);

//-------------------------------------------------------\
//Add everything to the playfeild
//-------------------------------------------------------/

add(solb);
add(birdb);
add(melob);
add(mouse);
}

//-------------------------------------------------------\
//Our Update Call
//-------------------------------------------------------/
override public function update():void
{
super.update();




}

//-------------------------------------------------------\
//Soli's Button
//-------------------------------------------------------/
private function soli():void {

Registry.Character = 1;

FlxG.fade(0xff000000, 2, changeState);
FlxG.music.fadeOut(2);




}

//-------------------------------------------------------\
//MElo's Button
//-------------------------------------------------------/
private function meloi():void {

Registry.Character = 3;
FlxG.fade(0xff000000, 2, changeState);
FlxG.music.fadeOut(2);



}

//-------------------------------------------------------\
//Revis Button
//-------------------------------------------------------/
private function birdi():void {
Registry.Character = 2;
FlxG.fade(0xff000000, 2, changeState);
FlxG.music.fadeOut(2);



}

//-------------------------------------------------------\
//Change State Function
//-------------------------------------------------------/
private function changeState():void
{
FlxG.switchState(new PlayState);

}

//-------------------------------------------------------\
//world Drestuciont *evil laugh*
//-------------------------------------------------------/
override public function destroy():void
{
FlxSpecialFX.clear();
super.destroy();
}

}

}

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: flxbuttonplus intermitting
« Reply #1 on: Sun, Jul 31, 2011 »
How are they being created / destroyed? The problem is probably here, as the buttons in the Demo Suite work fine no matter how many times you jump in and out of them.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

arcade27

  • Member
  • **
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: flxbuttonplus intermitting
« Reply #2 on: Sun, Jul 31, 2011 »
Everything to do with the buttons is handled inside the change character.as state

X__x I ahev a sneaky susspision im not destroying them



the code used to add a single button is..



private var soli_buttonflx:FlxSprite;
private var soli2_buttonflx:FlxSprite;
private var solb:FlxButtonPlus;

soli2_buttonflx = new FlxSprite(0, 0, soli_button2);
soli_buttonflx = new FlxSprite(0, 0, soli_button);

solb = new FlxButtonPlus(10, 10, soli, null, "", 300);
solb.loadGraphic(soli_buttonflx, soli2_buttonflx);

add(solb);   


now im assuming the destroy should be inside the



override public function destroy():void {

super.destroy
}


X__x sorry ive never delt with destroying before >...<