Hi once again...
Now I have a box2d object in my game, I wanted to add a Spring in my game and when a box2d object falls on the spring the spring should squeeze based on what force the object fall on it...
Can any one help me to reach to my this goal...
the sample of the spring is as follow....
and its a png image....
Comments
Then create distance joint with dynamic object attached to the ground wall.
More on joints:
http://appcodingeasy.com/Gideros-Mobile/Using-box2d-joints-in-Gideros
Then measure the distance between ground wall and dynamic object and scale the spring accordingly. This should give the effect of bouncing spring.
Hello sir..
As you told me to separate the top from the spring, I've created new images top and spring separately...
I've created both as dynamic body i.e both top and spring as dynamic body as follows:
in my init() function I'm calling
Now when I throw the pumpkin(box2d body) and when it falls on the spring top, the top of the spring falls down... I'm not getting any idea what has to be done..
Can me help me out to solve my problem..
whether what I'm doing is correct?
Please help me out.. First of all I'm new to gaming, and in that i'm working with lua, which is another new thing for me....
Thank you....
Let me try to create a simple example
And here is the video of how it looks like:
1) You will need to adjust frequency and dampeningRatio to the feel of the spring you want in your game
2) There are side supports, that will not allow dynamic body of distance joint to drop to the right and the left side, but they also affect other dynamic bodies. If you do not want that and want these side supports to affect only spring body, you can use collision filtering for that.
Here is a great tutorial on collision filters: http://www.giderosmobile.com/forum/discussion/1070/a-little-information-about-collision-filters/p1
3) to animate your spring you do not need to actually add it to the body, but rather place it as a bitmap image with anchor point to the bottom and then inside ENTER_FRAME event check the distance between the ground and the spring top body and scale the bitmap accordingly, you should get nice elastic effect from that (if you can provide separate top and spring images I can show you what I mean)
If you run into any more troubles, post here will try to solve that together, box2d stuff are so fun to play with
Likes: hgvyas123
Thank you so much for the example.... I'll try this now in my game...
Here are two different images attached...
I've provided spring and top of the spring separately in previous post, If i get how it works, then it will be really thankful...
waiting from your end...
Likes: fxone, MoKaLux
I tried the above code and its working fine....
Thanks alot...
Please don't mind, I'll be asking so many questions....
My next question is:
When i throw a pumpkin from a point and when it falls on the spring (which i created as above) the pumpkin does not bounce, in facts it slides and falls down...
I think because it of pumpkin weight..
How to set the mass of the body..
Or any other solutions will help..
Thank you
You can also try increasing friction of the pumpkin and spring also when creating fixture.
also playing with frequency of the spring might help.
It would be cool to see a video, if possible, that would help provide more suggestions
I'll try to take a video of my game..
It is very simple game, In fact it is a educational game for small kid..
It is a mathematical game, i.e to teach kids about numbers and rounding off...
The concept of my game is to throw a pumpkin from a place and when it falls on the ground, (there is a scale on the ground starting from 0, 0.5 and so on...) the kid have to enter the distance covered by the pumpkin..
but its not that much smooth...
I want to improve my game and deploy it as soon as possible on iOS and Android...
Please help me out for this..
thank you for all your support..
So if you already know where you want to throw the pumpkin before throwing it, you could attract pumpkin to specific spring like this:
http://appcodingeasy.com/Gideros-Mobile/Gideros--Box2d-magnets
Just an idea
@ar2rsawseen
I'm struggling to complete my game..
Please help me out to improve and to complete my game..
I was unable to record video of my game due to my PC problem...
So I've attached my project here..
Please go through it and help me out to improve it...
My code may look childish..
And what should be the width and height of the game to support in different devices..
My game is for Landscape mode..
Thank you....
Basically what I did was increasing pumkin density to gain weight,
and increasing spring's frequency for bounciness,
then reseting pumkin velocity on collision so it won't go further
and applying incoming velocity reflected by the x axis on collision with spring, so spring will throw it further (you may add coefficients there, to look to your need)
There were also a lot of your code in enterframe event which for some reason made pumkin roll back, so I just commented it out for now, so you can figure out the issue, cause I have no idea of purpose of that code
Thank you for your response...
The code in enterframe event is to check the position of the pumpkin when it is moving, i.e whether it touches the bottom ground and its linear velocity is 0, So that i can show TextInputDialog to enter the distance covered by the pumpkin...
And it also contains code to move all the background images from right to left when the pumpkin is thrown and it crossed half of the screen, and at the same time moving the pumpkin as well from right to left so that it always fall on the middle of the screen, and it seems to be moving long distance... Just like angry bird game effect..
Is there any other way to do this? without writing code in enterframe event....
Is there any problem with Gideros Player?
When i run this game in my Windows laptop the pumpkin travels very slow,
And same game when i run it in my MAC System, then it travels little faster than Win-Laptop
I want the pumpkin to travel with speed, so what should I do to solve this problem...
Whether it is a Emulator problem? Whether the game will be played fine in iPhone?
Either way it should run fine on the phones
Just now I saw a Video:
Gideros live coding with ZeroBrane Studio
but we need to create some extra lua files for that...
I don't wanna do live coding but instead I wanna check my game on iPhone/iPad or any android device in between by connecting my device using data cable.
How can I do this? :-?
http://docs.giderosmobile.com/deployment.html
I was trying to test my game on actual device but I was getting some error..
So I just created a video of the game which I've included here..
You can see that there is no smoothness in the movement.. its too slow and at the duration of 1:10 you can see the pumpkin bounces thrice then it is thrown from the spring...
and even when the pumpkin hits the edge of the spring its starts rotating...
So how do i fix all these problems...
Here I've one more problem to solve it..
When I throw my pumpkin then I'm scrolling the all background images from right to left by simply setting the X position of the each image, i.e imagename.setX(imagename.get() - 1) something like this...
I want to do same thing to my pumpkin so that it never touches the right wall and it should always falls at the middle of the screen but it must look like its moving forward..
I tried setting its X position but it doesn't work, as it is a box2d body...
How can I fix this problem...
If I apply force then the pumpkin roll's back when it touches the spring...
Please help me...
Something like this:
http://appcodingeasy.com/Gideros-Mobile/Gideros-Camera-Move
I've one background image, which is static, I'm not moving the main background image,
I've more than 1 images placed on background such as road, housed, mountains etc and I want to move all these images with different speed...
If I move the entire scene then all the Images will move at same speed...
I hope you will understand my problem, how exactly I want...
Just take a example of angry bird game, in which there are more than 1 background images such as mountains and all, but each moves at different speed, and when the angry bird is thrown it falls on the middle of the screen always or between some range but it seems to be moving forward..
This we can make out when we put some mark on the screen while playing the game and when the angry bird falls down, we will notice that every time it falls between some range..
I want something like this...
I tried to implement it, but its not working fine for me...
I referred http://appcodingeasy.com/Gideros-Mobile/Gideros-Camera-Move demo
but I'm unable to do it properly in my game..
I just want to check for right wall so, I've added only below code
2) for second/third/etc parallax backgrounds you can take scene position, invert it and apply some kind of coefficient for proper speed, for example:
Is it defining with self key word?
eg:
In my case as you know there is one spring attached to the bottom wall of the scene, so when I move the scene it also moves along with it....
There are 4 backgrounds
Background1 with the slowest which should move along with scene.
Followed by Background2 little faster than the Background1
Followed by Background3 faster than the Background2
Last Background the is fastest and the spring should move with the speed of this background...
How do I achieve this?
Thank you for your all time support...
creating backgrounds