Search Results

Search found 56 results on 3 pages for 'onupdate'.

Page 1/3 | 1 2 3  | Next Page >

  • setPosition of Sprite onUpdate in AndEngine

    - by SSH This
    I am trying to get a "highlighter" circle to follow around a sprite, but I am having trouble, I thought I could use the onUpdate method that's available to me in SequenceEntityModifier but it's not working for me. Here is my code: // make sequence mod with move modifier SequenceEntityModifier modifier = new SequenceEntityModifier(myMovemod) { @Override protected void onModifierFinished(IEntity pItem) { // animation finished super.onModifierFinished(pItem); } public float onUpdate(float pSecondsElapsed, IEntity pItem) { highlighter.setPosition(player2.getX() - highlighterOffset, player2.getY() - highlighterOffset); return pSecondsElapsed; } }; When onUpdate is completely commented out, the sprite moves like I want it to, everything is ok. When I put the onUpdate in, the sprite doesn't move at all. I have a feeling that I am overriding the original onUpdate's actions? Am I going about this the wrong way? I am new to Java, so please feel free to advise if this isn't going to work. UPDATE: The player2 is the sprite that I'm trying to get the highlighter to follow.

    Read the article

  • onUpdate in MySQL means?

    - by ajsie
    i know that if you create a foreign key on a field (parent_id) in a child table that refer to a parent table's primary key (id), then if this parent table is deleted the child class will be deleted as well if you set onDelete to cascade when creating the foreign key in the child class. but what happens if i set it to onUpdate = cascade?

    Read the article

  • How to update a Widget dynamically (Not waiting 30 min for onUpdate to be called)?

    - by Donal Rafferty
    I am currently learning about widgets in Android. I want to create a WIFI widget that will display the SSID, the RSSI (Signal) level. But I also want to be able to send it data from a service I am running that calculates the Quality of Sound over wifi. Here is what I have after some reading and a quick tutorial: public class WlanWidget extends AppWidgetProvider{ RemoteViews remoteViews; AppWidgetManager appWidgetManager; ComponentName thisWidget; WifiManager wifiManager; public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Timer timer = new Timer(); timer.scheduleAtFixedRate(new WlanTimer(context, appWidgetManager), 1, 10000); } private class WlanTimer extends TimerTask{ RemoteViews remoteViews; AppWidgetManager appWidgetManager; ComponentName thisWidget; public WlanTimer(Context context, AppWidgetManager appWidgetManager) { this.appWidgetManager = appWidgetManager; remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); thisWidget = new ComponentName(context, WlanWidget.class); wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE); } @Override public void run() { remoteViews.setTextViewText(R.id.widget_textview, wifiManager.getConnectionInfo().getSSID()); appWidgetManager.updateAppWidget(thisWidget, remoteViews); } } The above seems to work ok, it updates the SSID on the widget every 10 seconds. However what is the most efficent way to get the information from my service that will be already running to update periodically on my widget? Also is there a better approach to updating the the widget rather than using a timer and timertask? (Avoid polling) UPDATE As per Karan's suggestion I have added the following code in my Service: RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); ComponentName thisWidget = new ComponentName( context, WlanWidget.class ); remoteViews.setTextViewText(R.id.widget_QCLevel, " " + qcPercentage); AppWidgetManager.getInstance( context ).updateAppWidget( thisWidget, remoteViews ); This gets run everytime the RSSI level changes but it still never updates the TextView on my widget, any ideas why?

    Read the article

  • One to two relationship in Doctrine with YAML

    - by Jeremy DeGroot
    I'm working on my first Symfony project with Doctrine, and I've run into a hitch. I'm trying to express a game with two players. The relationship I want to have is PlayerOne and PlayerTwo each being keyed to an ID in the Users table. This is part of what I've got so far: Game: actAs: { Timestampable:- } columns: id: { type: integer, notnull: true, unique: true } startDate: { type: timestamp, notnull: true } playerOne: { type: integer, notnull: true } playerTwo: { type: integer, notnull: true } winner: { type: integer, notnull:true, default:0 } relations: User: { onUpdate: cascade, local: playerOne, foreign: id} User: { onUpdate: cascade, local: playerTwo, foreign: id} That doesn't work. It builds fine, but the SQL it generates only includes a constraint for playerTwo. I've tried a few other things: User: { onUpdate: cascade, local: [playerOne, playerTwo], foreign: id} Also: User: [{ onUpdate: cascade, local: playerOne, foreign: id}, { onUpdate: cascade, local: playerTwo, foreign: id}] Those last two throw errors when I try to build. Is there anyone out there who understands what I'm trying to do and can help me achieve it?

    Read the article

  • Andengine put bullet to pull, when it leaves screen

    - by Ashot
    i'm creating a bullet with physics body. Bullet class (extends Sprite class) has die() method, which unregister physics connector, hide sprite and put it in pull public void die() { Log.d("bulletDie", "See you in hell!"); if (this.isVisible()) { this.setVisible(false); mPhysicsWorld.unregisterPhysicsConnector(physicsConnector); physicsConnector.setUpdatePosition(false); body.setActive(false); this.setIgnoreUpdate(true); bulletsPool.recyclePoolItem(this); } } in onUpdate method of PhysicsConnector i executes die method, when sprite leaves screen physicsConnector = new PhysicsConnector(this,body,true,false) { @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if (!camera.isRectangularShapeVisible(_bullet)) { Log.d("bulletDie","Dead?"); _bullet.die(); } } }; it works as i expected, but _bullet.die() executes TWICE. what i`m doing wrong and is it right way to hide sprites? here is full code of Bullet class (it is inner class of class that represents player) private class Bullet extends Sprite implements PhysicsConstants { private final Body body; private final PhysicsConnector physicsConnector; private final Bullet _bullet; private int id; public Bullet(float x, float y, ITextureRegion texture, VertexBufferObjectManager vertexBufferObjectManager) { super(x,y,texture,vertexBufferObjectManager); _bullet = this; id = bulletId++; body = PhysicsFactory.createCircleBody(mPhysicsWorld, this, BodyDef.BodyType.DynamicBody, bulletFixture); physicsConnector = new PhysicsConnector(this,body,true,false) { @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if (!camera.isRectangularShapeVisible(_bullet)) { Log.d("bulletDie","Dead?"); Log.d("bulletDie",id+""); _bullet.die(); } } }; mPhysicsWorld.registerPhysicsConnector(physicsConnector); $this.getParent().attachChild(this); } public void reset() { final float angle = canon.getRotation(); final float x = (float) ((Math.cos(MathUtils.degToRad(angle))*radius) + centerX) / PIXEL_TO_METER_RATIO_DEFAULT; final float y = (float) ((Math.sin(MathUtils.degToRad(angle))*radius) + centerY) / PIXEL_TO_METER_RATIO_DEFAULT; this.setVisible(true); this.setIgnoreUpdate(false); body.setActive(true); mPhysicsWorld.registerPhysicsConnector(physicsConnector); body.setTransform(new Vector2(x,y),0); } public Body getBody() { return body; } public void setLinearVelocity(Vector2 velocity) { body.setLinearVelocity(velocity); } public void die() { Log.d("bulletDie", "See you in hell!"); if (this.isVisible()) { this.setVisible(false); mPhysicsWorld.unregisterPhysicsConnector(physicsConnector); physicsConnector.setUpdatePosition(false); body.setActive(false); this.setIgnoreUpdate(true); bulletsPool.recyclePoolItem(this); } } }

    Read the article

  • Andengine. Put bullet to pool, when it leaves screen

    - by Ashot
    i'm creating a bullet with physics body. Bullet class (extends Sprite class) has die() method, which unregister physics connector, hide sprite and put it in pool public void die() { Log.d("bulletDie", "See you in hell!"); if (this.isVisible()) { this.setVisible(false); mPhysicsWorld.unregisterPhysicsConnector(physicsConnector); physicsConnector.setUpdatePosition(false); body.setActive(false); this.setIgnoreUpdate(true); bulletsPool.recyclePoolItem(this); } } in onUpdate method of PhysicsConnector i executes die method, when sprite leaves screen physicsConnector = new PhysicsConnector(this,body,true,false) { @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if (!camera.isRectangularShapeVisible(_bullet)) { Log.d("bulletDie","Dead?"); _bullet.die(); } } }; it works as i expected, but _bullet.die() executes TWICE. what i`m doing wrong and is it right way to hide sprites? here is full code of Bullet class (it is inner class of class that represents player) private class Bullet extends Sprite implements PhysicsConstants { private final Body body; private final PhysicsConnector physicsConnector; private final Bullet _bullet; private int id; public Bullet(float x, float y, ITextureRegion texture, VertexBufferObjectManager vertexBufferObjectManager) { super(x,y,texture,vertexBufferObjectManager); _bullet = this; id = bulletId++; body = PhysicsFactory.createCircleBody(mPhysicsWorld, this, BodyDef.BodyType.DynamicBody, bulletFixture); physicsConnector = new PhysicsConnector(this,body,true,false) { @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if (!camera.isRectangularShapeVisible(_bullet)) { Log.d("bulletDie","Dead?"); Log.d("bulletDie",id+""); _bullet.die(); } } }; mPhysicsWorld.registerPhysicsConnector(physicsConnector); $this.getParent().attachChild(this); } public void reset() { final float angle = canon.getRotation(); final float x = (float) ((Math.cos(MathUtils.degToRad(angle))*radius) + centerX) / PIXEL_TO_METER_RATIO_DEFAULT; final float y = (float) ((Math.sin(MathUtils.degToRad(angle))*radius) + centerY) / PIXEL_TO_METER_RATIO_DEFAULT; this.setVisible(true); this.setIgnoreUpdate(false); body.setActive(true); mPhysicsWorld.registerPhysicsConnector(physicsConnector); body.setTransform(new Vector2(x,y),0); } public Body getBody() { return body; } public void setLinearVelocity(Vector2 velocity) { body.setLinearVelocity(velocity); } public void die() { Log.d("bulletDie", "See you in hell!"); if (this.isVisible()) { this.setVisible(false); mPhysicsWorld.unregisterPhysicsConnector(physicsConnector); physicsConnector.setUpdatePosition(false); body.setActive(false); this.setIgnoreUpdate(true); bulletsPool.recyclePoolItem(this); } } }

    Read the article

  • javascript new Date(0) class shows 16 hours?

    - by Jonah
    interval = new Date(0); return interval.getHours(); The above returns 16. I expect it to return 0. Any pointers? getMinutes() and getSeconds() return zero as expected. Thanks! I am trying to make a timer: function Timer(onUpdate) { this.initialTime = 0; this.timeStart = null; this.onUpdate = onUpdate this.getTotalTime = function() { timeEnd = new Date(); diff = timeEnd.getTime() - this.timeStart.getTime(); return diff + this.initialTime; }; this.formatTime = function() { interval = new Date(this.getTotalTime()); return this.zeroPad(interval.getHours(), 2) + ":" + this.zeroPad(interval.getMinutes(),2) + ":" + this.zeroPad(interval.getSeconds(),2); }; this.start = function() { this.timeStart = new Date(); this.onUpdate(this.formatTime()); var timerInstance = this; setTimeout(function() { timerInstance.updateTime(); }, 1000); }; this.updateTime = function() { this.onUpdate(this.formatTime()); var timerInstance = this; setTimeout(function() { timerInstance.updateTime(); }, 1000); }; this.zeroPad = function(num,count) { var numZeropad = num + ''; while(numZeropad.length < count) { numZeropad = "0" + numZeropad; } return numZeropad; } } It all works fine except for the 16 hour difference. Any ideas?

    Read the article

  • Component-based Rendering

    - by Kikaimaru
    I have component Renderer, that Draws Texture2D (or sprite) According to component-based architecture i should have only method OnUpdate, and there should be my rendering code, something like spriteBatch.Draw(Texture, Vector2.Zero, Color.White) But first I need to do spriteBatch.Begin();. Where should i call it? And how can I make sure it's called before any Renderer components OnUpdate method? (i need to do more stuff then just Begin() i also need to set right rendertarget for camera etc.)

    Read the article

  • setImageViewResource Sometimes loads image and sometimes it doesn't.

    - by Niv
    Hi All, I'm writing a simple widget which has an imageview widget that is supposed to load an image dynamically. To do this, I'm starting a service in the onUpdate method of the service. I validated that the service is running, however, the image is loaded only once every 10 times. Here is the code: (In the Original extends AppWidgetProvider) @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Log.d(LOG_TAG, "onUpdate(): Starting Service..1"); context.startService(new Intent(context, UpdateService.class)); } (The service:) @Override public void onStart(Intent intent, int startId) { Log.d(LOG_TAG, "(OnStart) In On Start..!"); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, Original.class)); for (int appWidgetId : appWidgetIds) { RemoteViews remoteView = new RemoteViews(this.getPackageName(), R.layout.widget); remoteView.setImageViewResource(R.id.widgetImage, R.drawable.let02); remoteView.setTextViewText(R.id.widget_textview_month, "aaa"); Log.d(LOG_TAG, "(OnUpdate) Set All Fields!"); appWidgetManager.updateAppWidget(appWidgetId, remoteView); } //super.onStart(intent, startId); return; }

    Read the article

  • Engine Start and Stop Show Abnormal Behaviour

    - by Siddharth
    In my game, when I pause the game using mEngine.stop() it works perfectly but when I press resume button that has code mEngine.start() it provide some movement to the physics body. So the created body does not stand at its desire position after the resuming the game. That fault I have found in other game developed by other developer also. So please provide some guidance for it. I also tried with mScene.onUpdate(0) and mScene.onUpdate(1) but I does not able to found anything new from it.

    Read the article

  • java.lang.NoClassDefFoundError at Runtime Android Widget

    - by pxrb66
    I have a problem during runtime of my Android widget with Android 2.3.3 and older. When i install my widget on the screen, this error is printed : 11-03 10:26:31.127: E/AndroidRuntime(404): FATAL EXCEPTION: main 11-03 10:26:31.127: E/AndroidRuntime(404): java.lang.NoClassDefFoundError: com.app.myapp.StackWidgetService 11-03 10:26:31.127: E/AndroidRuntime(404): at com.app.myapp.StackWidgetProvider.onUpdate(StackWidgetProvider.java:229) 11-03 10:26:31.127: E/AndroidRuntime(404): at android.appwidget.AppWidgetProvider.onReceive(AppWidgetProvider.java:61) 11-03 10:26:31.127: E/AndroidRuntime(404): at com.app.mobideals.StackWidgetProvider.onReceive(StackWidgetProvider.java:216) 11-03 10:26:31.127: E/AndroidRuntime(404): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794) 11-03 10:26:31.127: E/AndroidRuntime(404): at android.app.ActivityThread.access$2400(ActivityThread.java:117) 11-03 10:26:31.127: E/AndroidRuntime(404): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981) 11-03 10:26:31.127: E/AndroidRuntime(404): at android.os.Handler.dispatchMessage(Handler.java:99) 11-03 10:26:31.127: E/AndroidRuntime(404): at android.os.Looper.loop(Looper.java:123) 11-03 10:26:31.127: E/AndroidRuntime(404): at android.app.ActivityThread.main(ActivityThread.java:3683) 11-03 10:26:31.127: E/AndroidRuntime(404): at java.lang.reflect.Method.invokeNative(Native Method) 11-03 10:26:31.127: E/AndroidRuntime(404): at java.lang.reflect.Method.invoke(Method.java:507) 11-03 10:26:31.127: E/AndroidRuntime(404): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 11-03 10:26:31.127: E/AndroidRuntime(404): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 11-03 10:26:31.127: E/AndroidRuntime(404): at dalvik.system.NativeStart.main(Native Method) The problem is due to the fact that the compilator don't arrive to perform the link to the StackWidgetService class at this line in onUpdate method of StackWidgetProvider class : public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // update each of the widgets with the remote adapter for (int i = 0; i < appWidgetIds.length; ++i) { // Here we setup the intent which points to the StackViewService which will // provide the views for this collection. Intent intent = new Intent(context, StackWidgetService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]); The widget works well with other version of Android like 3.0, 4.0 etc... Please help me :)

    Read the article

  • Android - I can't make a widget clickable to launch an intent

    - by Daniele
    Hi all. I am new to Android development. I have developed a very simple widget that was meant to interact with the user via an ImageButton. What I am trying to do now is as follows. When a user taps the button (after adding the widget to their home screen), I want the phone to dial a certain telephone number. A sort of speed dial for your home screen. Unfortunately when I tap the button nothing happens. This is the body of my SpeedDialAppWidgetProvider.onUpdate method: Log.d("", "beginning of onUpdate"); final int N = appWidgetIds.length; for (int i=0; i<N; i++) { int appWidgetId = appWidgetIds[i]; Log.d("", "dealing with appWidgetId: " + appWidgetId); // Create an Intent to launch ExampleActivity Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:1234567")); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, dialIntent, 0); Log.d("", "pendingIntent classname " + pendingIntent.getClass().getName()); // Get the layout for the App Widget and attach an on-click listener to the button RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.speed_dial_appwidget); remoteViews.setOnClickPendingIntent(R.id.dial_icon, pendingIntent); Log.d("", "remoteViews classname " + remoteViews.getClass().getName()); // Tell the AppWidgetManager to perform an update on the current App Widget appWidgetManager.updateAppWidget(appWidgetId, remoteViews); Log.d("", "end of onUpdate"); I can see the method is called and the result of the logging makes sense. The speed_dial_appwidget.xml file is like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" androidrientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageButton id="@+id/dial_icon" android:src="@drawable/speed_dial" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> Can you please help me with this? Thanks in advance, Dan

    Read the article

  • How: Start an Activity inside a Thread and use finish() to get back.

    - by Kirk Becker
    Hello, I am programming a game on android. I'm using a Thread while calling a Surface View class to update and draw my game. Inside the update I wanted to start an activity based on if the game has just started and this would launch my MENUS. My Thread for the most part.. while (myThreadRun) { Canvas c = null; try { gameTime = System.currentTimeMillis(); c = myThreadSurfaceHolder.lockCanvas(null); synchronized (myThreadSurfaceHolder) { // Update Game. myThreadSurfaceView.onUpdate(); // Draw Game. myThreadSurfaceView.onDraw(c); You can see there where I am updating the game... here is onUpdate(); protected void onUpdate() { // Test if menu needs to be displayed. while (thread.getMenu()) { // Test if menu activity has been started. if (thread.getMenuRunning() == false) { Intent menuIntent = new Intent(this.getContext(), MyMenu.class); ((Activity) cxt).startActivityForResult(menuIntent, 1); thread.setMenuRunning(true); } } I am using a while loop because if I didn't use it the thread just keeps going. Basically I just don't know how to implement my menus using a thread as a game loop. Everywhere I look it seems like that's best practice. In my menu activity I just display the menu layout and a few buttons and when the person wants to start the game it uses finish() to go back to my thread where they play the game. I am very new to this so any insight will be helpful, Thanks

    Read the article

  • How to specify an association relation using declarative base

    - by sam
    I have been trying to create an association relation between two tables, intake and module . Each intake has a one-to-many relationship with the modules. However there is a coursework assigned to each module, and each coursework has a duedate which is unique to each intake. I tried this but it didnt work: intake_modules_table = Table('tg_intakemodules',metadata, Column('intake_id',Integer,ForeignKey('tg_intake.intake_id', onupdate="CASCADE",ondelete="CASCADE")), Column('module_id',Integer,ForeignKey('tg_module.module_id', onupdate ="CASCADE",ondelete="CASCADE")), Column('dueddate', Unicode(16)) ) class Intake(DeclarativeBase): __tablename__ = 'tg_intake' #{ Columns intake_id = Column(Integer, autoincrement=True, primary_key=True) code = Column(Unicode(16)) commencement = Column(DateTime) completion = Column(DateTime) #{ Special methods def __repr__(self): return '"%s"' %self.code def __unicode__(self): return self.code #} class Module(DeclarativeBase): __tablename__ ='tg_module' #{ Columns module_id = Column(Integer, autoincrement=True, primary_key=True) code = Column(Unicode(16)) title = Column(Unicode(30)) #{ relations intakes = relation('Intake', secondary=intake_modules_table, backref='modules') #{ Special methods def __repr__(self): return '"%s"'%self.title def __unicode__(self): return '"%s"'%self.title #} When I do this the column duedate specified in the intake_module_table is not created. Please some help will be appreciated here. thanks in advance

    Read the article

  • How to update widgets from a service?

    - by Franklin
    I have a background service that can be configured to perform some action every x minutes. I want to implement a widget that gets updated every time my service performs that action. However, I can't get the onUpdate method of my AppWidgetProvider called in any way, except when adding a widget to the homescreen. I tried sending APPWIDGET_UPDATE intents but onUpdate did not get called although the AppWidgetProvider did receive the intent since the onReceive method was called. Is there any way I can trigger widget updates from a service?

    Read the article

  • Sortable with scriptaculous problems

    - by user195257
    hello, Im following a few tutorials to sort a list, but i can't get the DB to update. The drag drop side of things is working, also, i javascript alert() the serialize list onUpdate and the order is printed out as follows: images_list[]=20&images_list[]=19 etc... So the sorting and dragging is working fine, i just cant get the database to update, this is my code. <script type="text/javascript"> Sortable.create("images_list", { onUpdate: function() { new Ajax.Request("processor.php", { method: "post", parameters: { data: Sortable.serialize("images_list") } }); } }); processor.php code: //Connect to DB require_once('connect.php'); parse_str($_POST['data']); for ($i = 0; $i < count($images_list); $i++) { $id = $images_list[$i]; mysql_query("UPDATE `images` SET `ranking` = '$i' WHERE `id` = '$id'"); } Any ideas would be great, thankyou!

    Read the article

  • Coordinate based travel through multi-line path over elapsed time

    - by Chris
    I have implemented A* Path finding to decide the course of a sprite through multiple waypoints. I have done this for point A to point B locations but am having trouble with multiple waypoints, because on slower devices when the FPS slows and the sprite travels PAST a waypoint I am lost as to the math to switch directions at the proper place. EDIT: To clarify my path finding code is separate in a game thread, this onUpdate method lives in a sprite like class which happens in the UI thread for sprite updating. To be even more clear the path is only updated when objects block the map, at any given point the current path could change but that should not affect the design of the algorithm if I am not mistaken. I do believe all components involved are well designed and accurate, aside from this piece :- ) Here is the scenario: public void onUpdate(float pSecondsElapsed) { // this could be 4x speed, so on slow devices the travel moved between // frames could be very large. What happens with my original algorithm // is it will start actually doing circles around the next waypoint.. pSecondsElapsed *= SomeSpeedModificationValue; final int spriteCurrentX = this.getX(); final int spriteCurrentY = this.getY(); // getCoords contains a large array of the coordinates to each waypoint. // A waypoint is a destination on the map, defined by tile column/row. The // path finder converts these waypoints to X,Y coords. // // I.E: // Given a set of waypoints of 0,0 to 12,23 to 23, 0 on a 23x23 tile map, each tile // being 32x32 pixels. This would translate in the path finder to this: // -> 0,0 to 12,23 // Coord : x=16 y=16 // Coord : x=16 y=48 // Coord : x=16 y=80 // ... // Coord : x=336 y=688 // Coord : x=336 y=720 // Coord : x=368 y=720 // // -> 12,23 to 23,0 -NOTE This direction change gives me trouble specifically // Coord : x=400 y=752 // Coord : x=400 y=720 // Coord : x=400 y=688 // ... // Coord : x=688 y=16 // Coord : x=688 y=0 // Coord : x=720 y=0 // // The current update index, the index specifies the coordinate that you see above // I.E. final int[] coords = getCoords( 2 ); -> x=16 y=80 final int[] coords = getCoords( ... ); // now I have the coords, how do I detect where to set the position? The tricky part // for me is when a direction changes, how do I calculate based on the elapsed time // how far to go up the new direction... I just can't wrap my head around this. this.setPosition(newX, newY); }

    Read the article

  • Can I get a reference to a pending transaction from a SqlConnection object?

    - by Rune
    Hey, Suppose someone (other than me) writes the following code and compiles it into an assembly: using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (var transaction = conn.BeginTransaction()) { /* Update something in the database */ /* Then call any registered OnUpdate handlers */ InvokeOnUpdate(conn); transaction.Commit(); } } The call to InvokeOnUpdate(IDbConnection conn) calls out to an event handler that I can implement and register. Thus, in this handler I will have a reference to the IDbConnection object, but I won't have a reference to the pending transaction. Is there any way in which I can get a hold of the transaction? In my OnUpdate handler I want to execute something similar to the following: private void MyOnUpdateHandler(IDbConnection conn) { var cmd = conn.CreateCommand(); cmd.CommandText = someSQLString; cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); } However, the call to cmd.ExecuteNonQuery() throws an InvalidOperationException complaining that "ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized". Can I in any way enlist my SqlCommand cmd with the pending transaction? Can I retrieve a reference to the pending transaction from the IDbConnection object (I'd be happy to use reflection if necessary)?

    Read the article

  • Android - update widget text

    - by david
    Hi, i have 2 questions about widgets update I have 2 buttons and i need to change one button text when i press the other one, how can i do this? The first time i open the widget it calls the onUpdate method, but it never calls it again. I need to update the widget every 2 seconds and i have this line in the xml. android:updatePeriodMillis="2000" Do i need a service or should it works just with the updatePeriodMillis tag? onUpdate method RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.newswidget); Intent intent = new Intent(context, DetalleConsulta.class); intent.putExtra(DetalleConsulta.CONSULTA_ID_NAME, "3"); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.btNews, pendingIntent); /* Inicializa variables para llamar el controlador */ this.imei = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); this.controlador = new Controlador(this.imei); try { this.respuestas = this.controlador.recuperarNuevasRespuestas(); if(this.respuestas != null &amp;&amp; this.respuestas.size() &gt; 0){ Iterator&lt;Consulta&gt; iterRespuestas = this.respuestas.iterator(); views.setTextViewText(R.id.btNews, ((Consulta)iterRespuestas.next()).getRespuesta()); } } catch (PersistenciaException e) { //TODO manejar error } appWidgetManager.updateAppWidget(appWidgetIds, views); thx a lot!!!

    Read the article

  • How to stop a tap event from propagating in a XNA / Silverlight game

    - by Mech0z
    I have a game with Silverlight / XNA game where text and buttons are created in Silverlight while 3d is done in XNA. The Silverlight controls are drawn ontop of the 3D and I dont want a click on a button to interact with the 3D underneath So I have private void ButtonPlaceBrick_Tap(object sender, GestureEventArgs e) { e.Handled = true; But my gesture handling on the 3d objects still runs even though I have set handled to true. private void OnUpdate(object sender, GameTimerEventArgs e) { while (TouchPanel.IsGestureAvailable) { // Read the next gesture GestureSample gesture = TouchPanel.ReadGesture(); switch (gesture.GestureType) How am I supposed to stop it from propagating?

    Read the article

  • Attributes and Behaviours in game object design

    - by Brukwa
    Recently I have read interesting slides about game object design written by Marcin Chady Theory and Practice of the Game Object Component Architecture. I have prototyped quick sample that utilize all Attributes\Behaviour idea with some sample data. Now I have faced a little problem when I added a RenderingSystem to my prototype application. I have created an object with RenderBehaviour which listens for messages (OnMessage function) like MovedObject in order to mark them as invalid and in OnUpdate pass I am inserting a new renderable object to rederer queue. I have noticed that rendering updates should be the last thing made in single frame and this causes RenderBehaviour to depend on any other Behaviour that changes object position (i.ex. PhysicsSystem and PhysicsBehaviour). I am not even sure if I am doing this the way it should be. Do you have any clues that might put me on the right track?

    Read the article

  • One-to-many relationship in the same table in zend

    - by Behrang
    I have groupTable(group_id,group_name,group_date,group_parent_id) in face each group have many group child I create groupModel and I want to begin coding is this right code to handle protected $_name = 'group'; protected $_dependentTables = array('Model_group'); protected $_referenceMap = array('Model_group' = array('columns' = array('group_parent_id') , 'refTableClass' = 'Model_group' , 'refColumns' = array('group_id') , 'onDelete' = self::CASCADE , 'onUpdate' = self::RESTRICT) );

    Read the article

1 2 3  | Next Page >