Oi sirs! Well, after put the following code inside my project my gameplay world suddenly freeze itself, making impossilble to the player class to interact with it.
override public function update():void
{
var collectedCoins:Vector.<Coin> = new Vector.<Coin>();
var conta:int = classCount(Coin);
conta = 5;
collidePoint('coin', posx, posy, collectedCoins);
if (collectedCoins.length > 0)
{
for each (var collectedCoin:Coin in collectedCoins)
{
// Remove the coins, play a little song, whatever.
collectedCoin.collect();
}
}
else
{
if (conta == 0)
{
// The player beat this stage! Good job!
FP.world = new W_GameO();
}
}
}
and now the world
package
{ import net.flashpunk.World; import net.flashpunk.FP; import net.flashpunk.Entity; //import Pinco; //import Coin;
public class W_gameplay extends World
{
//private var back:Background;
//private var _player:Pinco;
private var posx:int; private var posy:int;
public function W_gameplay()
{
super();
/*back = new Background(0,0);
add(back);
FP.world.camera.x += 10 * FP.elapsed;
FP.world.camera.y += 10 * FP.elapsed;
FP.screen.color = 0x333300;*/
add(new Pinco);
/*_player = Pinco(add(new Pinco()));*/
//trace("The player is currently located at", _player.x, player.y);
for (var i:int = 0; i < 50; i++)
{
add(new Muro2(i,0)); //soffitto
add(new Muro2(i,25)); //pavimento
}
for (i = 0; i < 25; i++)
{
add(new Muro2(0,i)); //muro sinistro
add(new Muro2(49,i)); //muro destro
}
//add(new Muro(1, 24)); //muro pilota, origine degli assi
add(new Muro(1, 5));
/*
*
//add(new Spike(1, 4)); //spike di prova
//add(new Acid(4, 12)); //acid di prova
//add(new Brucalippo(17, 27)); //bruco di prova
//add(new Muro(4, 2));
*
*/
for (i = 1; i < 5; i++)
{
add(new Muro(1, i + 12));
add(new Muro(5, i + 8));
add(new Muro(5, i + 16));
add(new Muro(5, i + 20));
add(new Muro(i + 7, 4));
add(new Muro(i + 4, 12));
add(new Muro(i + 4, 16));
add(new Muro(8, i + 11));
add(new Muro(4 + i, 8));
}
for (i = 1; i < 20; i++)
{
add(new Muro(16, i));
}
for (i = 1; i < 4; i++)
{
add(new Muro(8, i + 4));;
}
for (i = 1; i < 8; i++)
{
add(new Muro(15 + i, 20));
add(new Muro(22, 13 + i));
add(new Muro(29, 13 + i));
}
for (i = 1; i < 25; i++)
{
add(new Muro(29, 4 + i));
}
for (i = 1; i < 7; i++)
{
add(new Muro(22, i));
}
for (i = 1; i < 3; i++)
{
add(new Muro(16 + i, 10));
}
for (i = i; i < 6; i++)
{
add(new Muro(20 + i, 6));
add(new Muro(17 + i, 6));
add(new Muro(26 +i, 4));
}
for (i = 1; i < 10; i++)
{
add(new Muro(30 + i, 4));
add(new Muro(28, 9 + i));
add(new Muro(30 + (i / 2), 9));
add(new Muro(40 + (i / 2), 9));
add(new Muro(34 + i, 14));
add(new Muro(39 + i, 19));
add(new Muro(34,9+i));
}
add(new Muro(27, 14));
add(new Muro(15, 19));
//inserimento Coin nel livello
add(new Coin(1, 1));
add(new Coin(7, 10));
add(new Coin(20, 4));
add(new Coin(31, 11));
add(new Coin(47, 22));
}
override public function update():void
{
// Checkig function (collect all the coin!)
var collectedCoins:Vector.<Coin> = new Vector.<Coin>();
var conta:int = classCount(Coin);
conta = 5;
collidePoint('coin', posx, posy, collectedCoins);
if (collectedCoins.length > 0)
{
// Yay player! You got some coins!
for each (var collectedCoin:Coin in collectedCoins)
{
// Remove the coins, play a little song, whatever.
collectedCoin.collect();
}
}
else
{
// The player didn't get any coins. Maybe they're all collected!
if (conta == 0)
{
// The player beat this stage! Good job!
FP.world = new W_GameO();
}
}
}
}}
Anyone have a clue of the possible reason why this happen? Thanks!