SpriteSheet Help
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
SpriteSheet Help
I was trying this spritesheet that my friend sent me. Ive tried multiple ways which wasnt efficient so I tried this but now Im getting an error I dont know whats wrong. I tried my best to debug it but I cant see it. If theres a better way of doing this, just reply with it. Thanks
-
- Prole
- Posts: 15
- Joined: Tue Oct 17, 2017 11:26 pm
Re: SpriteSheet Help
you need to make sure activeF is not nil when first drawing the player
coz it's not going to be magically 0.1 seconds later in the first frame
coz it's not going to be magically 0.1 seconds later in the first frame
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: SpriteSheet Help
Ive found my mistake there. Sorry for that, I have fixed it and the only problems are when the player moves it doesnt transition to the walking animation
Re: SpriteSheet Help
You need to increment your table index CF.KyleFlores1014 wrote: ↑Thu Oct 19, 2017 12:06 pm Ive found my mistake there. Sorry for that, I have fixed it and the only problems are when the player moves it doesnt transition to the walking animation
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: SpriteSheet Help
Will this transition my sprite to the walking animation? and how do I do this?
Re: SpriteSheet Help
Code: Select all
ETime = ETime + dt
if ETime > 0.1 then
CF = CF + 1
if CF > total then
CF = 1
end
activeF = frames[CF]
ETime = 0
end
You're also indexing your "Player.png" image incorrectly, you need to take into account the vertical position of your quads, not just horizontal.
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: SpriteSheet Help
I didnt realize that but now I have fixed and now im recieving an error when pressing A or D? I dont know why it does this
Re: SpriteSheet Help
Notice I wrote
In your code you have
The reason why you're getting that error is that you increment CF but never limit what value it can be, meaning it will be incremented forever and you'll start indexing your table where you did not intend.
Code: Select all
if CF > total then
Code: Select all
if CF < total then
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: SpriteSheet Help
I tried it but still does the same. It can be read after the 3rd or 4th walking animation, also I have tried testing each frame and it works I just dont know why it does this.
Re: SpriteSheet Help
It should be
But you're setting the 'total' to 8 for WalkR and WalkL, when it should be 6 in those cases. You can ditch the 'total' variable altogether if you use
You seem to be struggling with very basic concepts, I recommend you try to go through your code line by line and think of what happens when each line gets executed and in what order will they get executed.
Code: Select all
if CF > total then
Code: Select all
if CF > #frames then
Who is online
Users browsing this forum: Google [Bot] and 46 guests