Object flicker colors + on and off help? [4.5]

Yan

Member
I've made a simple invicibility variable so my player character won't be able to get stuck being hit over and over again without being able to fight back, it works fine but there is no way to tell when it starts and ends since my character doesn't change at all. So how do I make my character sprite flicker on and off whenever that specific variable is above zero?

(I'm also using Davey's sprite cycling [http://nesmakers.com/viewtopic.php?f=40&t=5960] that cycles all objects except the player character in case that interferes with anything)

I would also appreciate if anyone could tell me a way to make the enemies change palette for a few frames after being hit before going back to their original color.

thanks in advance and sorry if that has been asked before :lol:
 

dale_coop

Moderator
Staff member
NESmaker 4.5 ?
Like in the tutorials, you could just a flickering animation (2 frames, 1 with graphics and 2 with empty gfx) and assign that animation to your hurt action step.
 

Yan

Member
Yeah it's on 4.5 (added that to the title now)

The flickering on a specific animation isn't exactly what I'm looking for here since I want my player to freely move and stuff while flickering
 

Yan

Member
I was finally able to make my character flicker on and off (I'm sure there are many better ways to do this though) :lol:

Basically I wanted my character to flicker on and off every time a variable named "invincibilityTimer" was above zero so I created another variable named "flickeringPlayer" and added this simple thing at the top of "Handle Game Timer" :

Code:
LDA flickeringPlayer
BEQ +add
DEC flickeringPlayer
JMP +next
+add
INC flickeringPlayer
+next

Then in "Handle Drawing Sprites" I added this right after the "doDrawThisSprite:" :

Code:
    LDA invincibilityTimer
    BNE +continue
    JMP +normalStart
    +continue  
    TXA
    CMP player1_object
    BNE +normalStart
    LDA flickeringPlayer
    BNE +normalStart
    JMP doneDrawingThisSprite
    +normalStart
 

dale_coop

Moderator
Staff member
When I add this script, I sometimes have this bug of sprite animation. Does anyone know how to fix it?

View attachment 7576

Instead of placing the code at the beginning of the doDrawSprites script, you could try placing it later in the script.

Locate the "DrawSprite tempA, tempB, tempC, tempD" line (around the end of the script) and place the code just BEFORE that line, and you need to change the code for that:
Code:
    LDA invincibilityTimer
    BNE +continue
      JMP +normalStart
    +continue:
    CPX player1_object
    BNE +normalStart
      LDA flickeringPlayer
      BNE +normalStart
        JMP thisTileIsOffScreen
    +normalStart:
 

TalkingCat

Member
Instead of placing the code at the beginning of the doDrawSprites script, you could try placing it later in the script.

Locate the "DrawSprite tempA, tempB, tempC, tempD" line (around the end of the script) and place the code just BEFORE that line, and you need to change the code for that:
Code:
    LDA invincibilityTimer
    BNE +continue
      JMP +normalStart
    +continue:
    CPX player1_object
    BNE +normalStart
      LDA flickeringPlayer
      BNE +normalStart
        JMP thisTileIsOffScreen
    +normalStart:
Thanks Dale, it solved the problem (y)
 
Top Bottom