From game maker to Construct: some questions.

For questions about using Classic.

Post » Sun Mar 14, 2010 1:56 am

Hi,

I came from game maker, so I have some questions in order to traslate my skills in Construct.


How you traslate this?

a) when a obj_a is create, it create a obj_b in obj_a.x and obj_a.y
[code:chdj1vjy]
obj_a:
Create Event:
instance_create(x,y,obj_b)
[/code:chdj1vjy]
b) look if there are a obj_c at 40 X pixel from me, if yes, change variable in obj_c
[code:chdj1vjy]
obj=instance_position(x+40,y,obj_c)
if obj != noone
{
with(obj)
{
name = "Olaf"
}
}
[/code:chdj1vjy]
c) obj_a pick obj_b and compare private variable
[code:chdj1vjy]
obj_a
create event:
color = choose("red","blue","green")
step event:
P_08 = instance_position(x,y-altezza,b_obj)
if P_08 != noone
{
if (P_08.color = color)
{
...
}
}
[/code:chdj1vjy]
B
7
G
2
Posts: 14
Reputation: 1,078

Post » Sun Mar 14, 2010 2:44 am

a)
[code:3napcu8k]+ System: Timer is Equal to 1000
-> System: Create object Sprite on layer 1 at (400, 300)
-> System: Create object Sprite2 on layer 1 at (Sprite.X, Sprite.Y)
[/code:3napcu8k]
Or if you will always be creating those two objects together, put both into a container so when one is created they will both be created.
[code:3napcu8k]+ System: Timer is Equal to 1000
-> System: Create object Sprite on layer 1 at (400, 300)
-> Sprite2: Set position to object Sprite (image point 0)
[/code:3napcu8k]

b)
[code:3napcu8k]+ Sprite: overlaps Sprite2 : offset (40,0)
-> Sprite2: Flash for 2 seconds with 0.1 seconds interval
[/code:3napcu8k]

c)
[code:3napcu8k]+ Sprite: Value 'color' Equal to Sprite2.Value('color')
-> Sprite: Flash for 2 seconds with 0.1 seconds interval
-> Sprite2: Flash for 2 seconds with 0.1 seconds interval
[/code:3napcu8k]

Hope that helps :)
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Sun Mar 14, 2010 2:58 am

Note about containers: When you destroy one object in a container, it destroys all objects in the container. They essentially come as packages.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Sun Mar 14, 2010 1:14 pm

[quote="R0J0hound":fz0t8bc5]

Hope that helps :)[/quote:fz0t8bc5]
Yes. Thank you! :D

One more question:

If in case B, there are not two Sprite different, but two instances of same Sprite, how to flash ONLY the one at +100X form the other?

B
7
G
2
Posts: 14
Reputation: 1,078

Post » Sun Mar 14, 2010 4:54 pm

Change the event:

Flashactivator overlaps flashingthing -> Flash flashingthing

to this:

flashingthing overlaps Flashactivator -> Flash flashingthing

That should do the trick.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Sun Mar 14, 2010 5:05 pm

[quote="Aureus":orsmic96][quote="R0J0hound":orsmic96]

Hope that helps :)[/quote:orsmic96]
Yes. Thank you! :D

One more question:

If in case B, there are not two Sprite different, but two instances of same Sprite, how to flash ONLY the one at +100X form the other?

[/quote:orsmic96]

I cold think of a few ways, but here's one using the family picking trick:
http://dl.dropbox.com/u/529356/TempPics/greenflash.cap
v0.99.84

The green sprites are in the Green family, which is then used to distinguish between instances of the same object. Any questions feel free to ask.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Mar 14, 2010 11:41 pm

[quote="deadeye":2ovm4h2e][quote="Aureus":2ovm4h2e][quote="R0J0hound":2ovm4h2e]

Hope that helps :)[/quote:2ovm4h2e]
Yes. Thank you! :D

One more question:

If in case B, there are not two Sprite different, but two instances of same Sprite, how to flash ONLY the one at +100X form the other?

[/quote:2ovm4h2e]

I cold think of a few ways, but here's one using the family picking trick:
http://dl.dropbox.com/u/529356/TempPics/greenflash.cap
v0.99.84

The green sprites are in the Green family, which is then used to distinguish between instances of the same object. Any questions feel free to ask.[/quote:2ovm4h2e]
Thank you, it is perfect!
B
7
G
2
Posts: 14
Reputation: 1,078

Post » Tue Mar 16, 2010 2:42 am

[quote="deadeye":30klcvpt]
I cold think of a few ways, but here's one using the family picking trick:
http://dl.dropbox.com/u/529356/TempPics/greenflash.cap
v0.99.84

The green sprites are in the Green family, which is then used to distinguish between instances of the same object. Any questions feel free to ask.[/quote:30klcvpt]

It works, and this is somewhat unrelated, but if you change the target from the overlap from the green family to GreenSprite, the game crashes. Why is this? Families work here, but I don't know why they do.

On a side note, this is the one thing I dislike most about Construct. I personally find the event system hard to use when you have many of the same object, such as in this instance. You used a family to solve this problem, but why did it work? If I needed to do this myself, I would have ended up doing it the way I told you above, and resulted in a crash. Next, I'd try all kinds of craziness with private variables and whatnot, but some things in Construct just don't seem intuitive to say the least.

This coming from an old Gamemaker user, so needless to say, I'm used to each object working independently without having to work out which ones will be affected by the global event sheet. Construct is so much better in so many ways, but manipulating individual instances is hard for me to wrap my head around with the event system controlling everything.
B
3
S
1
G
2
Posts: 57
Reputation: 964

Post » Tue Mar 16, 2010 3:36 am

[quote="greyspot":19v2k3dc]
On a side note, this is the one thing I dislike most about Construct. I personally find the event system hard to use when you have many of the same object, such as in this instance. You used a family to solve this problem, but why did it work? If I needed to do this myself, I would have ended up doing it the way I told you above, and resulted in a crash. Next, I'd try all kinds of craziness with private variables and whatnot, but some things in Construct just don't seem intuitive to say the least.

This coming from an old Gamemaker user, so needless to say, I'm used to each object working independently without having to work out which ones will be affected by the global event sheet. Construct is so much better in so many ways, but manipulating individual instances is hard for me to wrap my head around with the event system controlling everything.[/quote:19v2k3dc]

I switched form GM in mid January so slightly a head of the curve from you.
I found it hard to switch but see the power. And still find GM scripting easier, but can not do so many things in GM that I can do in Construct, so hang in there.

Try this to understand Families:
http://sourceforge.net/apps/mediawiki/c ... e=Families

But also look at Containers:
http://sourceforge.net/apps/mediawiki/c ... Containers
They will make you sprite life easier


The other important thing that will make you project much easier to handle is using event sheets and including them.

Oh and start small and grow. You will learn faster that way.
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Tue Mar 16, 2010 5:08 am

[quote="greyspot":lbjysplq]It works, and this is somewhat unrelated, but if you change the target from the overlap from the green family to GreenSprite, the game crashes. Why is this? Families work here, but I don't know why they do.[/quote:lbjysplq]

Families are a way to group objects together. When you do that, you can test conditions and perform actions on the group. The group is treated as a separate entity where picking is concerned.

In this case, the family is a group of one. The sprite is the only object in there. But this means that we can now refer to the object in two different ways... by it's object-self, and by the group-self. So... now you can check if Sprite is overlapping Family without any conflict. It's just a trick to make instances of the same object interact, it's not really what Families were designed for.

For more info on picking, and the Selected Object List, check out the wiki:
http://sourceforge.net/apps/mediawiki/c ... ct_picking
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests