Cycle through animation sprites

Get help using Construct 2

Post » Fri Nov 08, 2013 6:37 pm

Hi, I'm on day two of trying to work out how to do this and still no closer...

I want, button A and button B to cycle through a set of images on touch in different directions

Button A on touch would change the main sprite animation frame to 5 then on touch again 4, then on touch 3 etc and go round in a loop back to 5.

Button B on touch would count up - touch would show 3 then touch 4 touch 5 etc

I know how to do this in flash, really easy but I'm a graphics man and stuck on how best to do it using construct

any help would be appreciated

cheers
Dave
B
5
Posts: 15
Reputation: 328

Post » Fri Nov 08, 2013 7:13 pm

give the sprite a variable
- on a touched add 1 to variable
- on b touched subtract 1 from variable
- if variable = -1 - set variable to 5
- if variable = 6 - set variable to 0
- sprite set animationframe to variable
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Nov 08, 2013 8:04 pm

Hi, thanks for the reply, still no idea how to do it.

I've got it in my mind and its really simple, just don't understand the code and how to add it

thanks anyway
Dave
B
5
Posts: 15
Reputation: 328

Post » Fri Nov 08, 2013 8:39 pm

Which of the events I described above don't you understand?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Nov 08, 2013 9:08 pm

@Dseipp capx
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Post » Sun Nov 10, 2013 5:04 pm

Thanks @Cipriux that's exactly what I was trying to do, very much appreciated :)

@LittleStain I need to doing some learning I think. Thank you for your help as well :)

cheers
Dave
B
5
Posts: 15
Reputation: 328

Post » Sun Nov 10, 2013 8:38 pm

@Dseipp everyone need to learn, especially if is new at something.
From my point of view it is vital to know this concepts:
- object, instance (C2 refer to plugin as as object, which is misleading since in programming an object is an instance created from a class, in C2 an instance is created from a plugin/object (not sure about that)).
- variable (constant, static, local, global)
- dt (deltatime) this is useful when you make movement to have the same speed no matter the FPS of the game
- in C2 , the "code" run from top to bottom every frame with exceptions:
    - triggered events run ONCE when the condition is true (they have a arrow on the icon)
    - every x seconds...duh, run every x seconds
- "self" to be used when pointing to the same object that the action is referring about (Sprite.Angle = self.Angle+10 is better than Sprite.Angle = Sprite.Angle+10) "self" is more portable to other objects and actions. "self" is the same as "this" in programmming
- and more :)Cipriux2013-11-10 20:39:49
B
78
S
21
G
23
Posts: 513
Reputation: 18,623


Return to How do I....?

Who is online

Users browsing this forum: Malhog and 18 guests