A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 35 of 35

Thread: solitaire game need help

  1. #21
    Senior Member
    Join Date
    May 2016
    Posts
    451
    very good
    It is better when the word appears, the timing begins, and not before the word appears in first time
    Can you modify this please?
    Last edited by kofa; 05-18-2022 at 11:59 AM.

  2. #22
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    For line 7 of the solitaire_play script you would just need to change the 1 second delay to 0 seconds.

    Change 1000ms to 0ms
    PHP Code:
    var timeout_1=setTimeout(player_time,1000,turn); 
    PHP Code:
    var timeout_1=setTimeout(player_time,0,turn); 
    Line 54 I commented this out as well
    PHP Code:
    //_root.solitaire.solitaire_play.data_field.text="It is " + player_turn[turn] + " " + "turn." 
    I will get to fixing the bugs when I get time later if you want to list them, because i'm sure that when 1 player didn't make a move you want to give the other player a score?

    download solitaire 11

  3. #23
    Senior Member
    Join Date
    May 2016
    Posts
    451
    Allow me to re-explain the game:
    First press the red or black player button
    Secondly, the word appears and the timing begins
    Thirdly, Drag and drop the word card to the number card
    Fourth, press the other player's button to start the same steps

  4. #24
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I just added this function for the solitaire_play script called "released", it gets called when a card gets swiped to give the next user a turn with a timer.

    This is the function inside the solitaire_play script, so when a red card gets swiped up the card has its internal function for release & calls _parent.released("red"); which is in the function inside the solitaire_play script:
    PHP Code:
    function released(a){
    if(
    a=="red"){
    this.time_1=this.default_timeout//since it is the next players turn now we reset this.time_1 back to default which is 12 seconds.
    this.timeout_1=setTimeout(this.player_time,1000,0);//timeout_1 stores the timeout so you can call clearTimeout if needed later.
    _root.solitaire.solitaire_play.red_btn.enabled=false
    _root
    .solitaire.solitaire_play.black_btn.enabled=true
    }

    if(
    a=="black"){
    this.time_1=this.default_timeout//since it is the next players turn now we reset this.time_1 back to default which is 12 seconds.
    this.timeout_1=setTimeout(this.player_time,1000,1);//timeout_1 stores the timeout so you can call clearTimeout if needed later.
    _root.solitaire.solitaire_play.red_btn.enabled=true
    _root
    .solitaire.solitaire_play.black_btn.enabled=false
    }

    When ticks reaches 40 in function pick for either card I commented out the timeout to give the next user a turn for red and black since the next turn will be given from a card swipe. :
    PHP Code:
    //this.timeout_1=setTimeout(this.player_time,1000,1);//timeout_1 stores the timeout so you can call clearTimeout if needed later. 


    For black0, black1, black2, black3 etc.. inside the release function for the card:
    PHP Code:
     _parent.released("black"); 
    For red0, red1, red2, red3 etc.. inside the release function for the card:
    PHP Code:
     _parent.released("red"); 
    download solitaire 12
    Last edited by AS3.0; 05-31-2022 at 01:41 PM.

  5. #25
    Senior Member
    Join Date
    May 2016
    Posts
    451
    can you disable drag after dropping the card

    try drag the card again and look at timer ( problem )
    Last edited by kofa; 05-31-2022 at 02:22 PM.

  6. #26
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Ok each card that had an internal release function with this call "_parent.released("red");" can have "this" as reference for the card

    PHP Code:
    _parent.released("red",this);  //this is reference to the card in the released function thats in the solitiare_play script 
    so in the solitaire_play script "b" = the card so we can do b.enabled = false to disable it.

    b is "this", reference to the card and it gets disabled from this function
    PHP Code:
    function released(a,b){
    b.enabled=false
    if(a=="red"){
    this.time_1=this.default_timeout//since it is the next players turn now we reset this.time_1 back to default which is 12 seconds.
    this.timeout_1=setTimeout(this.player_time,1000,0);//timeout_1 stores the timeout so you can call clearTimeout if needed later.
    _root.solitaire.solitaire_play.red_btn.enabled=false
    _root
    .solitaire.solitaire_play.black_btn.enabled=true
    }

    if(
    a=="black"){
    this.time_1=this.default_timeout//since it is the next players turn now we reset this.time_1 back to default which is 12 seconds.
    this.timeout_1=setTimeout(this.player_time,1000,1);//timeout_1 stores the timeout so you can call clearTimeout if needed later.
    _root.solitaire.solitaire_play.red_btn.enabled=true
    _root
    .solitaire.solitaire_play.black_btn.enabled=false
    }

    download solitaire 13

  7. #27
    Senior Member
    Join Date
    May 2016
    Posts
    451
    Can you edit after pressing the button the timing starts not after dropping the card
    Last edited by kofa; 05-31-2022 at 03:44 PM.

  8. #28
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    1.) Click to play.
    2.) Time starts for random card.
    3.) Card makes move.
    4.) Card swipes up.
    5.) Text tells the next person to go, no timer until next person clicks card.

    Or did you expect :

    1.) Click to play.
    2.) Text tells the person to go, no timer until card gets clicked.
    3.) Player clicks his card.
    4.) Player swipes up.
    5.) Text tells the next person to go, no timer until next person clicks card.

    download solitiare 14

    I left my job so I will be programming more lately but I need to make a batch of 3D Android games to sell.
    Last edited by AS3.0; 06-15-2022 at 03:33 PM.

  9. #29
    Senior Member
    Join Date
    May 2016
    Posts
    451
    1.) Click to play.
    2.) Text tells the person to go, no timer until card gets clicked.
    3.) Player clicks his button ( red or black ).
    4.) Timing starts
    5.) Player drag and drop his card. ( if timing end before drag and drop ==> the next player start and ready to click his button , no timer start until click button )
    6.) Player swipes up.
    7.) Text tells the next person to go, no timer until next person clicks card.

  10. #30
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Ok I am pretty sure this covers what you asked.

    For the timer to not start when it says "click to play game" on line 7 of solitaire play I just put null & commented out the timer that would start immediately:
    PHP Code:
    var timeout_1=null//setTimeout(player_time,0,turn);//on start setTimeout for function below which is a timer subtraction for the text field above the card game. 
    So for line 10 that means we can just state who's turn it is to click a card by reading the textfield:
    PHP Code:
    if(turn==1){
    _root.solitaire.solitaire_play.data_field.text="It is red cards turn."
    }else{
    _root.solitaire.solitaire_play.data_field.text="It is black cards turn."

    What I did when the timer runs out for a user that had to swipe up is to output:
    PHP Code:
    _root.solitaire.solitaire_play.data_field.text="Black card didn't make a move on time, It is red cards turn." 
    On line 30 & 52 in solitaire_play script for both cards I also moved the card Mask back to -200 when the timer runs out while disabling the card from being swiped if the timer runs out:
    PHP Code:
    for(var i=0;i<10;i++){
     
    _root.solitaire.solitaire_play["black"+i].enabled=false
    }

    _root.solitaire.solitaire_play.Mask._x=-200 
    In the same section I also commented out the new timer since the next player must first click the card before a timer appears:
    PHP Code:
    //timeout_1=setTimeout(player_time,2500,turn);// lines 29 & 51 got commented out 


    download solitaire 15
    Last edited by AS3.0; 06-28-2022 at 12:00 PM.

  11. #31
    Senior Member
    Join Date
    May 2016
    Posts
    451

  12. #32
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Ok I fixed a bug where the card was being removed from the array too early.

    When ticks==40 on line 185 & 212 I just stored 2 variables:
    PHP Code:
    _parent.ran=ran;//the splice numbers local variable stored as a global variable on line 5
    _parent.col_num=0//the color number 0 or 1 stored as a global variable on line 6 
    On each cards release function for swipe I added this function call:
    PHP Code:
    _parent.removeCard(_parent.ran,_parent.col_num//we call function _parent.removeCard & give it the 2 global variables _parent.ran is splice number to remove the card & _parent.col_num is the cards color to know which array to remove it from. 
    On line 151 of solitaire_play this is the function that gets called from the card to remove an item from the card array:
    PHP Code:
    function removeCard(a,b){
    if(
    b==0){
    this.black_Mask.splice(a,1);
    }else{
    this.red_Mask.splice(a,1);
    }
    //_root.solitaire.solitaire_play._x=Number(red_Mask[a][1])

    download solitaire 16

  13. #33
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I fixed another issue where the card wasn't switching back to the pic attachment when a user doesn't make a move.

    On the main script in solitaire_play the variables on line 6 & 7 I added 2 variables called last_card_text & last_card_text2:
    PHP Code:
    var last_card_text
    var last_card_text2 
    In the script for each card that has an onFrame event for frame 2 I added _root.last_card_text=this;:
    PHP Code:
    onFrame (2) {
    _root.last_card_text=this;//black cards
    stop();

    PHP Code:
    onFrame (2) {
    _root.last_card_text2=this;//red cards
    stop();

    On lines 29 & 54 I added this so the text can be hidden & the pic can be reattached:
    PHP Code:
    _root.last_card_text.gotoAndStop(1);
    _root.last_card_text.pic.attachMovie("st1""st1"0

    That stuff is inside the player_time function from the solitaire_play script for when the timer runs out, to do that task.

    download solitaire 17
    Last edited by AS3.0; 07-01-2022 at 02:48 PM.

  14. #34
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    If the user clicks its card turn repeatedly, the timer messes up so this solves that issue.

    On line 186 & 187 the cards can be disabled on the first click:
    PHP Code:
    _root.solitaire.solitaire_play.black_btn.enabled=false
    _root
    .solitaire.solitaire_play.red_btn.enabled=false 
    Black card 2 had an issue when timing out because I put _parent. instead of _root..

    black2 card:
    PHP Code:
    onFrame (2) {
    _root.last_card_text=this;
        
    stop();

    download solitaire 18
    Last edited by AS3.0; 07-02-2022 at 10:08 AM.

  15. #35
    Senior Member
    Join Date
    May 2016
    Posts
    451
    you are a great person

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center