Plugin to allow images in the application mode?

New releases and general discussions.

Post » Mon Mar 10, 2014 7:59 pm

As the title suggests, i am looking for a way to show simple, static images in the application mode, that doesn't require Directx 9. Is there a plugin for this, or a way to do it with existing objects?
B
10
S
1
Posts: 163
Reputation: 1,436

Post » Mon Mar 10, 2014 8:07 pm

As far as I know, no.
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876


Post » Tue Mar 11, 2014 7:36 pm

It's good to hear that there's a workaround for this (as for pretty much anything in CC).
Also, if i have your attention already, would you know if there's an equivalent to the pin behaviour in C2, that would allow me to dynamically "link" objects together in CC as needed? Also, if this needs to be done manually, how would one handle the collisions, so that any collision affects all of the objects, even if there are multiple ones happening (some way of calculating force vectors with offsets and summing then together)?
B
10
S
1
Posts: 163
Reputation: 1,436

Post » Tue Mar 11, 2014 7:52 pm

There's the pairer object, you could use that which sort of works like a dynamic container (I haven't used it in long enough that I can't remember how well it would work for this purpose though), or you could store uids in instance variables as well as the offset distance and angle, then use a for each loop to place the objects each tick.
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876

Post » Tue Mar 11, 2014 8:17 pm

@Arima Well, i am thinking that simply placing objects relative to the "parent" one would probably cause problems because there would be no collision checks, and even if those would be performed, how could i possibly know how to handle moving all of the other sprites?
There's a couple of problems i see with this:
1.) pairing the objects - probably the easiest part to do, can be performed as you suggested
2.) checking for collisions - again, possible to do with little hassles, just simple events running for each objects
3.) reacting to collisions - probably has something to do with calculating the total force working upon the "structure", by finding out the vectors for each of the individual objects and summing them, this, of course, means that acceleration, mass and whatnot should also be accounted for, as you'd need to apply the force to the "parent" object that is divided by the count of the objects, thus resulting in the closest possible reaction that would realistically happen (F=ma), but of course this only works assuming that the mass parameters for all of the objects are equal. If not, you also need to calculate where the center of mass is located and take it into account. See why i think that this will cause problems? >_>

Either way, i thank you for your useful responses, however i was wondering if there's any post or thread where the inner workings of the C2 pin objects are described?
B
10
S
1
Posts: 163
Reputation: 1,436

Post » Wed Mar 12, 2014 3:16 am

You could look in the "exporters" folder to look at the source code of the pin behavior. If you want to do it in Construct Classic I think in the examples section there is an example of arrows sticking into an object, which does basically the same thing as the pin behavior.

Off the top of my head you could do pin like this:
1 Create two sprites, childSprite and parentSprite.

2 Give childSprite four instance variables: parent,dist,ang,relAng.
Parent will store the uid of the parentSprite to be pinned to, use -1 for none.
Dist and ang are the distance and angle to position from the parent.
RelAng is the relative angle between the parent and child.

3 Here's an example of an event to setup a pin.
On ChildSprite collides with parentSprite
---childSprite: set parent to parentSprite.uid
---childSprite: set dist to distance(parentSprite.x,parentSprite.y,self.x,self.y)
---childSprite: set ang to angle(parentSprite.x,parentSprite.y,self.x,self.y)
---childSprite: set relAng to self.angle-parentSprite.angle

4 Then position the pinned objects with:
For each childSprite
Pick parentSprite by uid childSprite.parent
---childSprite: set position to parentSprite
---childSprite: move self.dist pixels at angle self.ang
---childSprite: set angle to parentSprite.angle+self.relAng

Edit
The collision response will be interesting, you have choice of either doing the motion yourself or seeing if you can bend the physics behavior to your own devices. Either way you'll want the center of mass. Instead of just finding an average of the positions you need to incorporate mass which is simple enough.
COMx =(mass1*x1+mass2*x2...)/(count*total_mass)
COMy =(mass1*y1+mass2*y2...)/(count*total_mass)

And then you can calculate the force and torque to apply to it with roughly this:
Linear force =applied force magnitude* dist from com to applied force loc * cos(angle of applied force- angle from applied force to com)
Angular torque is the same as above except use sin instead of cos.
B
94
S
33
G
114
Posts: 5,357
Reputation: 73,775


Return to Construct Classic Discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests