-
mobile game (flash lite 1.1) - character not moving correctly
Hi, the game Im working on right now is modify from a tutorial game found on web - http://www.republicofcode.com/tutorials/flash/litegame/
this is the original code:
//Essential Variables
score = 0;
lives = 3;
//Positions the player on the stage.
new_player._x=0;
new_player._y=260;
new_player.myPosition=1;
I try to load variables from external file, and change player character everytime I change the value of variable 'player', so I modify the code to:
external file: &player=1&score=0&lives=3
//Essential Variables
score = Number(score);
lives = Number(lives);
switch(player){
case "1":
loadMovie("player1.swf","new_player");
break;
case "2":
loadMovie("player2.swf","new_player");
break;
case "3":
loadMovie("player3.swf","new_player");
break;
case "4":
loadMovie("player4.swf","new_player");
break;
}
//Positions the player on the stage.
new_player._x=0;
new_player._y=260;
new_player.myPosition=1;
the button code:
on (keyPress "4"){
if (new_player.myPosition != 1){
new_player.myPosition--;
new_player._x-=80;
}
}
on (keyPress "6"){
if (new_player.myPosition != 3){
new_player.myPosition++;
new_player._x+=80;
}
}
variables are loaded successfully but the player is not moving correctly after modified the code. anyone knows wht's the problem?
p/s: loadVariables() is not working in imode phone.. how to load external data in a imode phone?
-
Senior Member
Could you explain what exactly happens when you say "player is not moving correctly". Is it not moving at all? Is it moving into wrong position?
One thing that could happen is that once you load movie into new_player, its myPosition is deleted and so it becomes undefined. Try to trace the value of myPosition and see if it exist:
on (keyPress "4"){
trace(new_player.myPosition);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|