View Full Version : game development ( load || attach || duplicate )
sophistikat
05-02-2005, 05:40 PM
Hello Everyone,
i'm developing a game and i'm not sure whats the best way to accomplish the following; let me start by explaing the situation.
1. the game has ten external icons
2. there are fifteen movieclips on the stage
3. user click on a bttn
4. flash send and receives information from the server
5. flash display result
6. steps 3 - 5 repeat until the user quits the game.
when flash displays the result, do i keep using loadMovie? will the icons be cached on their computer.
Isn't there a way to load my icons in flash (have them off the stage) and when my function to display the results gets called, i just 'copy' the icons from the stage into my movieclips??
from what i've tried, attachMovie doesn't work because the icons are externally loaded into the game and therefore i can't give it a linkage name and duplicateMovieClip always asks for a new name.
does someone know a trick to getting around this or am i stuck using loadMovie?
pcarini
05-02-2005, 09:53 PM
And you absolutely can't use embed the icons in the same flash movie ? attachMovie always seems to be the most straightforward to me.
Is your main concern here download size? Browsers tend to cache .swf's as well as they cache image files, so once they've dl'd it there shouldn't be a difference between a movie w/ the icons embedded and a movie that loads them externally.
Note, however, that a complete load of a file or image will cause all subsequent loads to come from the browser cache.
hangalot
05-03-2005, 12:12 PM
yeah it loads from the cache, but you still need preloader code to check when it is finished loading.
sophistikat
05-03-2005, 02:39 PM
the game is a 5x3 Slot Machine and currently;
- the ten icons load off the screen (icon0 -9)
- i created fifteen movieclips, using duplicatemc(gameicon0 - 14)
- currently it loads the icons using loadMovie
attachMovie always seems to be the most straightforward to me.i would like to use attachMovie but, from what i know, you can't give a movieclip a linkage name when it's loaded externally.
i'm going to look into puting my current test version online to give you a better understanding of what i'm trying to accomplish. i'm thinking that we shouldn't load the icons externally and have them included with the flash file so that i can use attachMovie.
from what i know, you can't give a movieclip a linkage name when it's loaded externally.
That is correct.
hangalot
05-03-2005, 09:46 PM
from what i know, you can't give a movieclip a linkage name when it's loaded externally.
checkout rsl
pcarini
05-03-2005, 10:29 PM
And you absolutely can't use embed the icons in the same flash movie ? attachMovie always seems to be the most straightforward to me.
i'm thinking that we shouldn't load the icons externally and have them included with the flash file so that i can use attachMovie.
!!!!!!!! aargh! I don't know why I even bother anymore...
sophistikat
05-11-2005, 10:21 PM
pcarini, i was referring to what you said.
i've attached a zip file if you want to see where the game is at because it leads me to another question for you experts.
functions, is it smart to go from function to function when developing a game? i find that there are time during my game where i jump to another function and the previous function is still running...
check the following example, it works exactly how i want my functions to work, so i'm thinking that my script is missing something that keeps my previous function running. but more importantly, should i keep going function to function or is there a better way?
the following output returns 0 - 9 and done
i = 0;
one ();
function one () {
if (i == 0) {
do {
trace(i);
i++;
} while (i < 10);
}
//off two the next function
two ();
}
function two () {
// do something here
trace("done");
// off to the next function
}
stop ();
sleekdigital
05-11-2005, 10:35 PM
calling one function from another is very common, I don't see any problem here as long as you encapsulate functionality in a logical manner.
sophistikat
05-12-2005, 10:10 PM
sleekdigital can i ask you this and to everyone else because i'm losing my mind. here is what's happening in my output window right now, each --- ends that function
load our list
---
load our xml
---
create our clips
---
position our clips
---
load our movies
---
place our buttons
on there default position
---
I wait for the user to place their bet and press Spin
Spin
---
call the server and
get our next set of icons
---
If they win (right now its default is to win) this happens
delay the first line
---
show next line
---
show next line
---
show next line
---
remove last line
add our balace
---
Here's where it the :mad: hits the fan
balace = 310
---
remove last line
add our balace
---
balace = 320
---
remove last line
add our balace
---
balace = 330
---
remove last line
add our balace
---
balace = 340
---
remove last line
add our balace
---
balace = 350
---
remove last line
add our balace
---
balace = 360
---
remove last line
add our balace
---
balace = 370
---
remove last line
add our balace
---
balace = 380
---
remove last line
add our balace
---
initiate the buttons again
---
place our buttons
where we last left off
---
remove last line
add our balace
---
initiate the buttons again
---
place our buttons
where we last left off
What should happen after
remove last line
add our balace
---
is this
balace = 310
---
balace = 320
---
balace = 330
---
balace = 340
---
balace = 350
---
balace = 360
---
balace = 370
---
balace = 380
---
initiate the buttons again
---
place our buttons
where we last left off
---
now i wait to see if the user is going to spin again or change their bet.
here are my functions, when the user presses Spin initSpin is set to 1:
function showWinLines () {
/* display each winning line */
if (i < win_lines.length) {
if (i < 1) {
movetheClip (_root["win" + win_lines[i]], ind_win_x, ind_win_y[win_lines[i]]);
} else {
movetheClip (_root["win" + win_lines[i - 1]], ind_win_x_off, ind_win_y[win_lines[i - 1]]);
movetheClip (_root["win" + win_lines[i]], ind_win_x, ind_win_y[win_lines[i]]);
}
i++;
trace ("show next line\n---");
/* delay between each one */
delaytheGame (10, showWinLines);
} else {
/* remove the last one */
movetheClip (_root["win" + win_lines[i - 1]], ind_win_x_off, ind_win_y[win_lines[i]]);
trace ("remove last line\nadd our balace\n---");
addtheBalance ();
}
}
function addtheBalance () {
if (BA != NB) {
BA += 10;
WN -= 10;
trace ("balace = " + BA + "\n---");
} else {
trace ("initiate the buttons again\n---");
inittheButtons ();
}
}
function inittheButtons () {
if (initSpin == 0) {
trace ("place our buttons\non there default position\n---");
/* buttons */
movetheClip (invBtn0, btn_onSX[0], btn_offS);
movetheClip (invBtn1, btn_onSX[1], btn_offS);
movetheClip (invBtn2, btn_onSX[2], btn_onSY[2]);
movetheClip (invBtn3, btn_onSX[3], btn_offS);
movetheClip (invBtn4, btn_onSX[4], btn_onSY[4]);
movetheClip (invBtn5, btn_onSX[5], btn_onSY[5]);
movetheClip (invBtn6, btn_onSX[6], btn_onSY[6]);
movetheClip (invBtn7, btn_onSX[7], btn_offS);
/* graphics */
movetheClip (btn0_1, btn_onSX[0], btn_onSY[0]);
movetheClip (btn1_1, btn_onSX[1], btn_onSY[1]);
movetheClip (btn2_0, btn_onSX[2], btn_onSY[2]);
movetheClip (btn3_1, btn_onSX[3], btn_onSY[3]);
movetheClip (btn4_0, btn_onSX[4], btn_onSY[4]);
movetheClip (btn5_0, btn_onSX[5], btn_onSY[5]);
movetheClip (btn6_0, btn_onSX[6], btn_onSY[6]);
movetheClip (btn7_1, btn_onSX[7], btn_onSY[7]);
} else {
trace ("place our buttons\nwhere we last left off\n---");
if (PL == max_PL) {
movetheClip (invBtn1, btn_onSX[1], btn_onSY[1]);
swaptheClip (btn1_1, btn1_0, 1);
} else {
movetheClip (invBtn1, btn_onSX[1], btn_onSY[1]);
swaptheClip (btn1_1, btn1_0, 1);
movetheClip (invBtn2, btn_onSX[2], btn_onSY[2]);
swaptheClip (btn2_1, btn2_0, 2);
}
if (BL == max_BL) {
movetheClip (invBtn3, btn_onSX[3], btn_onSY[3]);
swaptheClip (btn3_1, btn3_0, 3);
} else {
movetheClip (invBtn3, btn_onSX[3], btn_onSY[3]);
swaptheClip (btn3_1, btn3_0, 3);
movetheClip (invBtn4, btn_onSX[4], btn_onSY[4]);
swaptheClip (btn4_1, btn4_0, 4);
movetheClip (invBtn5, btn_onSX[5], btn_onSY[5]);
swaptheClip (btn5_1, btn5_0, 5);
}
if (TB != max_TB) {
movetheClip (invBtn6, btn_onSX[6], btn_onSY[6]);
swaptheClip (btn6_1, btn6_0, 6);
}
/* clear */
movetheClip (invBtn0, btn_onSX[0], btn_onSY[0]);
swaptheClip (btn0_1, btn0_0, 0);
/* spin */
movetheClip (invBtn7, btn_onSX[7], btn_onSY[7]);
swaptheClip (btn7_1, btn7_0, 7);
}
}
i've been looking at this too long, can anyone see where its going wrong?
if you want see the complete madness you can email me and i'll send you the as files.
sleekdigital
05-13-2005, 01:26 AM
Its very difficult to follow what you are trying to do here without more explaination and the code that calls these functions, and the origin of alot of the variables.
sophistikat
05-13-2005, 04:17 PM
variables.as - declares all our variables
functions.as - functions reused during game play
initgame.as - sets up the game
buttons.as - for all our buttons basic and full functionality
play.as - what makes the game run
Here's how the game runs
* the variables are declared
* load our default icons
* load our xml and on success createtheClips();
* createtheClips();
create all my movieclips using attachMovie, duplicateMovieclip and
from each node's ID in my xml file, now go to positiontheClips ();
* positiontheClips ();
using a function called movetheClip (inside function.as), we position
all the movieclips to where they'll be on the start of the game. now go to arrangeDepth ();
* arrangeDepth ();
because the pay lines and win lines have to be on top of the icons,
i need to give them a new depth. now go to preLoader ();
* preLoader ();
haven't had time enough time to attempt this but i will need to preload
all the swf files from my xml, not import right now so this just loads each swf.
now go to activetheStates(); and inittheButtons(); and set c to 1 (counter)
* activatetheStates();
where i have the basic functionality for my buttons (rollover, press, release etc.)
* inittheButtons ();
if initSpin = 0 (place the buttons when the game starts and when the user hits clear all)
if initSpin = 1 (place the buttons where we last left off before the user hit Spin)
now we wait for the user to place there bet (activatetheStates();)
Everything up to this point is find and dandy, the basic and full functionality of our buttons work,
the paylines and indicators(numbers) work... so now the user is ready and hits Spin and goes to calltheServer ();
*calltheServer ();
for right now we are faking this function but will be just a simple http call so,
it goes to loadtheNextSet() and loops through my 5 txt files that fake the http call.
* loadtheNextSet();
load our txt files using new LoadVars ();
on success
get the list of icons
what lines are winners?
play our fake spin animations
go to delaytheGame (randomDelay (3, 5) , delayfirstLine);
* delaytheGame waits for two param. length and function
length = randomly delays the spin animation 3 - 5 seconds
function = tells it where to go from there
* delayfirstLine();
first stop the spin animations
convert WN (from our txt file) from string to number
an if statement checks
if WN is 0 go to inittheButtons();
else add our new balance and go to delaytheGame (5, showWinLines);
* showWinLines();
checks if all lines have been displayed
if no, checks to see if the first line has been displayed
if no, displays our first line and go to delaytheGame (10, showWinLines);
if yes, remove our previous line and display our next line and go to delaytheGame (10, showWinLines);
if yes, remove the last line and go to addtheBalance();
* addtheBalance();
checks to see if the users balance equals the new balance (which is balance plus won)
if they don't match
add balance plus 10
sub won minus 10
else
once the balance equals the new balance, go to inittheButton();
From here on end the last six function repeat them selve everytime the user hits Spin but at the moment,
my output windows shows me that when i call addtheBalance from showWinLines, showWinLines keeps calling
addtheBalance while addtheBalance is adding. It should call it once and let addtheBalance do its thing, when
addtheBalance is done its thing, it called inittheButton, it does its thing and we wait for the users input..
So my problem is that showWinLines, addtheBalance and inittheButton keep looping/playing/initiating but i don't see why showWinLines keep looping when it calls addtheBalance, please help. i'm not looking for someone to code this for me, i just want someone to see what i don't see. thanks.
sophistikat
05-16-2005, 10:09 PM
good lord!
i don't even know how to start explain my problem but i've fixed it and now i'm moving on, i used setInterval, a loop here and there and this problem went away.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.