Author Topic: How do you actually use buttons?  (Read 3093 times)

Derpyhoovesiwbtg

  • Spike Dodger
  • Posts: 176
  • ''My hands hurt''
    • View Profile
    • Clickity click!
  • Playstyle: Keyboard
How do you actually use buttons?
« on: August 13, 2013, 12:22:33 PM »
I have no idea how to use them, i cant find a tutorial anywhere.
« Last Edit: August 15, 2013, 06:47:53 AM by Denferok »
I have no idea what to put here.

Anyway, a lot of things have changed to myself in the past. I wont visit the forum much, but i will check out the streams once in a while.

Sephalos

  • Spike Dodger
  • Posts: 228
    • View Profile
  • Playstyle: Gamepad
Re: How do you actually use triggers?
« Reply #1 on: August 13, 2013, 02:25:21 PM »
Well what engine are you using?

Derpyhoovesiwbtg

  • Spike Dodger
  • Posts: 176
  • ''My hands hurt''
    • View Profile
    • Clickity click!
  • Playstyle: Keyboard
Re: How do you actually use buttons?
« Reply #2 on: August 13, 2013, 03:05:22 PM »
Oops, i've meant actually how to use buttons. F-my self. But still, how you use buttons?
I have no idea what to put here.

Anyway, a lot of things have changed to myself in the past. I wont visit the forum much, but i will check out the streams once in a while.

Sephalos

  • Spike Dodger
  • Posts: 228
    • View Profile
  • Playstyle: Gamepad
Re: How do you actually use buttons?
« Reply #3 on: August 13, 2013, 03:20:35 PM »
You're gonna have to be more specific than that. What buttons? and what are you trying to do?

Derpyhoovesiwbtg

  • Spike Dodger
  • Posts: 176
  • ''My hands hurt''
    • View Profile
    • Clickity click!
  • Playstyle: Keyboard
Re: How do you actually use buttons?
« Reply #4 on: August 13, 2013, 04:27:41 PM »
Hittable buttons you can hit with your gun.
I have no idea what to put here.

Anyway, a lot of things have changed to myself in the past. I wont visit the forum much, but i will check out the streams once in a while.

Sephalos

  • Spike Dodger
  • Posts: 228
    • View Profile
  • Playstyle: Gamepad
Re: How do you actually use buttons?
« Reply #5 on: August 13, 2013, 05:12:51 PM »
Well alright, let's start with something basic then.

Make a object called 'oButton'
The sprite should have 2 frames, on and off.

--------------------
Create Event:
image_speed = 0;
io = 0;
--------------------
Collision with Bullet event:
if io = 0 { image_index = 1; io = 1; }
else if io = 1 { image_index = 0; io = 0; }
with(other){ instance_destroy(); }
--------------------

There you have it, one shootable button.  :TriHard:

Derpyhoovesiwbtg

  • Spike Dodger
  • Posts: 176
  • ''My hands hurt''
    • View Profile
    • Clickity click!
  • Playstyle: Keyboard
Re: How do you actually use buttons?
« Reply #6 on: August 14, 2013, 04:01:05 AM »
It works but, when i hit it multiple times, it fades from blue to red, blue to red, and so on.

But how i actually use it with stuff like spikes?
I have no idea what to put here.

Anyway, a lot of things have changed to myself in the past. I wont visit the forum much, but i will check out the streams once in a while.

Sephalos

  • Spike Dodger
  • Posts: 228
    • View Profile
  • Playstyle: Gamepad
Re: How do you actually use buttons?
« Reply #7 on: August 14, 2013, 02:39:37 PM »
Alright, I'm going to assume you want spikes to come up and down when you press the button.
You're going to need a couple objects for this.

oButtonSpikeUp1
--------------------
Create Event:
image_speed = 0;
io = 0;
ys = y;
--------------------
Step Event:
if io = 0 { if y > ys { y -= 2; } }
if io = 1 { if y < ys+32 { y += 2; } }
--------------------

oButtonSpikeDown1
--------------------
Create Event:
image_speed = 0;
io = 0;
ys = y;
--------------------
Step Event:
if io = 0 { if y < ys { y += 2; } }
if io = 1 { if y > ys-32 { y -= 2; } }
--------------------

oButtonSpikeUp2
--------------------
Create Event:
image_speed = 0;
io = 0;
ys = y;
--------------------
Step Event:
if io = 0 { if y < ys { y += 2; } }
if io = 1 { if y > ys-32 { y -= 2; } }
--------------------

oButtonSpikeDown2
--------------------
Create Event:
image_speed = 0;
io = 0;
ys = y;
--------------------
Step Event:
if io = 0 { if y > ys { y -= 2; } }
if io = 1 { if y < ys+32 { y += 2; } }
--------------------

oButton
--------------------
Create Event:
image_speed = 0;
io = 0;
--------------------
Collision with Bullet event:
if io = 0 {
image_index = 1;
io = 1;
with(oButtonSpikeUp1){ io = 1; }
with(oButtonSpikeDown1){ io = 1; }
with(oButtonSpikeUp2){ io = 1; }
with(oButtonSpikeDown2){ io = 1; }
} else if io = 1 {
 image_index = 0;
 io = 0;
with(oButtonSpikeUp1){ io = 0; }
with(oButtonSpikeDown1){ io = 0; }
with(oButtonSpikeUp2){ io = 0; }
with(oButtonSpikeDown2){ io = 0; }
}
with(other){ instance_destroy(); }
--------------------


Hope this helps, let me know if something goes horribly wrong.
« Last Edit: August 14, 2013, 06:34:20 PM by Sephalos »

Derpyhoovesiwbtg

  • Spike Dodger
  • Posts: 176
  • ''My hands hurt''
    • View Profile
    • Clickity click!
  • Playstyle: Keyboard
Re: How do you actually use buttons?
« Reply #8 on: August 15, 2013, 04:39:08 AM »
Thanks Sephalos, everything worked. Please lock this thread :)
I have no idea what to put here.

Anyway, a lot of things have changed to myself in the past. I wont visit the forum much, but i will check out the streams once in a while.

Denferok

  • Community Manager
  • The Kid
  • Administrator
  • Posts: 355
    • View Profile
    • My stream
  • Playstyle: Keyboard
Re: How do you actually use buttons?
« Reply #9 on: August 15, 2013, 06:48:52 AM »
Locked