Jump to content

  • Log In with Google      Sign In   
  • Create Account

LoneWolfe007

Member Since 27 Feb 2011
Offline Last Active Jul 11 2014 10:51 PM

Topics I've Started

Adding a picture file to a drawn rectangle

13 May 2014 - 08:46 PM

Hello all,

 

I did research before I decided to post this so at least I know I can read and follow directions. The code I have draws rectangles, which is awesome, but I have been wracking my brain trying to figure out how to replace the rectangles with a picture I made instead of just filling them in with the color brown. I will attach some pictures so this isn't as crazy sounding as I type it here.

 

Current rectangles: https://db.tt/Nq72xGm8

New rectangles after picture added: https://db.tt/ny9rD2ye

 

After doing a search on your site I found some references but not sure if they exactly answer the question I am asking. Here is the code chunk I would like help with:

///////////////////////////////////////////////////////////////////
// Add rectangles at top increasing height at start and decreasing
// at the end. These rectangles will move from right to left side
// of the screen and increase in height with time to make game herder.
//////////////////////////////////////////////////////////////////
float upX= 0;
float heightUp= 30;
heightPlus= 5;
for(int i= 0; i<30; i++){
final int num= i;
final Rectangle rect= new Rectangle(upX, 0, 60, heightUp){
protected void onManagedUpdate(float pSecondsElapsed){
if(state== 50){
heightPlus= 0;
}
if(this.getX()+ this.getWidth()<0){
this.setHeight(this.getHeight()+ heightPlus);
if(num==0){
this.setPosition(rectsUp.get(29).getX()+ rectsUp.get(29).getWidth(), this.getY());
}else{
this.setPosition(rectsUp.get(num-1).getX()+ rectsUp.get(num-1).getWidth(), this.getY());
}
}

if(this.collidesWith(copterCollider) && !gameOver){
gameOver= true;
}
super.onManagedUpdate(pSecondsElapsed);
}
};
rect.setColor(colorRed/255f, colorGreen/255f, colorBlue/255f);
scene.attachChild(rect);
rectsUp.add(rect);
final PhysicsHandler rectHandler= new PhysicsHandler(rect);
rect.registerUpdateHandler(rectHandler);
rect.setUserData(rectHandler);
rectHandlers.add(rectHandler);
if(num<15){
heightUp+= 3;
}else{
heightUp-= 3;
}
upX+= 60;
}

I understand that the picture has to be called and inserted but I suppose I assumed it would be a lot easier than what it is turning out to be because the rectangles are already drawn.

 

My thought on the subject is that at the point where the code reads: rect.setColor(colorRed/255f, colorGreen/255f, colorBlue/255f); I would keep the code the way it is basically but change setColor to call the picture or even change the variables in a way to show the picture instead of colors. After looking on Google I found a few posts that were in the ball park that talked about using a specific code, but it is slightly confusing to me how to implement it. The main article I found is located  here: http://stackoverflow.com/questions/15247971/fill-rectangle-with-image-in-java and in that same article is a second link which takes me to a website with a tutorial: http://docs.oracle.com/javase/tutorial/2d/images/drawimage.html.

 

Could someone explain to me in a more simplified English what exactly to do? I'm not looking for step by step just a better idea on how to accomplish my goal.

Any help on the subject would be fantastic, thank you in advance.

~Michael


Android game ad spamming to gain money...

12 May 2014 - 08:44 PM

So I was thinking about this for a little bit now and am curious if this is possible. Some developers tend to add ads into their games, some ads are full screen and some are just the little banner ones. The way I understand them is that if an ad pops up, depending on the type that is used, and the player clicks on it the developer gains money, if i am incorrect please inform me. Anyway if I were the developer of a mobile game couldn't I just click on my games ads all day and gain an easy $50 bucks?


*hypothetical* If Nintendo had to sell...

25 January 2014 - 10:45 AM

I've been a huge Nintendo fan since I was a kid. I’m also not much for understanding how the business industry works, but my friend Nate and I were having this conversation at work about who Nintendo would sell too if they had to. My thought is Nintendo would sell to PlayStation since they are old competitors. Nate believes they would sell to Microsoft because they offer that “whole system experience”…apparently (I don’t agree). Anywho so I was curious what others think? If Nintendo had to stop making home consoles what do you think they would do with their mascots (Mario, Zelda, etc.)?


PARTNERS